diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 3bed66bd05..d5fee5fec1 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -52,6 +52,36 @@ export default async () => { link: "/architecture/opentelemetry-transport-context", }, { text: "Secret Management", link: "/architecture/secret-management" }, + { text: "Session Aggregate", link: "/architecture/session-aggregate" }, + { text: "Session Artifacts", link: "/architecture/session-artifacts" }, + { text: "Session Crash Boundaries", link: "/architecture/session-crash-boundaries" }, + { text: "Session Detached Work", link: "/architecture/session-detached-work" }, + { text: "Session Doctor", link: "/architecture/session-doctor" }, + { text: "Session Maintenance", link: "/architecture/session-maintenance" }, + { text: "Session Pagination", link: "/architecture/session-pagination" }, + { + text: "Session Presentation Caches", + link: "/architecture/session-presentation-cache", + }, + { + text: "Session Projection Freshness", + link: "/architecture/session-projection-freshness", + }, + { text: "Session Provider Faults", link: "/architecture/session-provider-faults" }, + { text: "Session Query Contract", link: "/architecture/session-queries" }, + { text: "Session Resume Index", link: "/architecture/session-resume-index" }, + { + text: "Session Schema Boundaries", + link: "/architecture/session-schema-boundaries", + }, + { text: "Session Structured Diff", link: "/architecture/session-structured-diff" }, + { text: "Session Terminal Replay", link: "/architecture/session-terminal-replay" }, + { text: "Session Title and Preview", link: "/architecture/session-title-and-preview" }, + { text: "Session Tool Effects", link: "/architecture/session-tool-effects" }, + { + text: "Usage Settlement Ledger", + link: "/architecture/usage-settlement-ledger", + }, ], }, { diff --git a/docs/adr/0035-session-store-decider-aggregate.md b/docs/adr/0035-session-store-decider-aggregate.md index 4850025dd5..d57dd62c04 100644 --- a/docs/adr/0035-session-store-decider-aggregate.md +++ b/docs/adr/0035-session-store-decider-aggregate.md @@ -1246,6 +1246,15 @@ Storage is otherwise managed without ever removing a fact: logically deletes an event, and whether to enable it is deferred to deployment, not decided here. + **Amended by [ADR#0059](./0059-session-stream-incarnation-fencing.md).** Eviction + from a live session subject is no longer admissible in any form. A partially + evicted subject leaves this facet's `At(current_position)` guard comparing + against a sequence that no longer names the event the writer read, and a fully + evicted one resolves to `NoStream`, so a redelivered creation command starts a + second history under an identity that already has one. A deployment that must + bound the hot stream rebuilds into a new stream incarnation and seals the old + one; it does not edit the stream it is running on. + Because nothing is ever logically removed, the machinery an archive-then-purge design would need -- a verified-archive KV ledger, a fork-lineage watermark term so a live fork's source prefix is not purged, and the purge-versus-new-fork race -- simply @@ -1259,7 +1268,19 @@ needs, checkpointing `last_applied_stream_position` after each event exactly as the scheduler does. Queries are `verb + noun` Rust functions over the KV projection ([ADR#0014](./0014-command-and-query-naming.md)) -- `get_session`, `list_sessions` -- with no query protos, since the projection value is the read -contract. The model-visible context is compiled deterministically by applying +contract. + +**Amended by [ADR#0060](./0060-session-query-contract-separate-from-projection.md).** +The clause "with no query protos, since the projection value is the read +contract" is withdrawn. A projection exists to be cheaply rebuilt and a public +contract exists to hold still, and one type cannot carry both obligations: either +the projection stops changing freely, which removes the property that made it +worth rebuilding, or the contract changes at the projection's cadence, which +means it is not a contract. The read contract is a versioned query proto under +`sessions/queries/v1alpha1` whose value types are redefined locally rather than +imported. Everything else in this facet stands: no read model is authoritative, +projections are folded and checkpointed from the log, and the handlers are still +`verb + noun` Rust functions reading the KV projection. The model-visible context is compiled deterministically by applying rewind invalidation through the selected head before choosing the newest usable `Compacted` marker (facet 4). For a fork with no usable child marker, the projection recursively resolves the source context named by its diff --git a/docs/adr/0059-session-stream-incarnation-fencing.md b/docs/adr/0059-session-stream-incarnation-fencing.md new file mode 100644 index 0000000000..b7df447531 --- /dev/null +++ b/docs/adr/0059-session-stream-incarnation-fencing.md @@ -0,0 +1,272 @@ +--- +number: "0059" +slug: session-stream-incarnation-fencing +status: draft +date: 2026-08-21 +--- + +# ADR#0059: Stream Incarnation Fencing by Subject Isolation and Sealing + +## Context + +[ADR#0035](./0035-session-store-decider-aggregate.md) facet 2 gives the Session +aggregate optimistic concurrency through a single server-side guard. The runtime +resolves the default [write precondition](../glossary/write-precondition) to +`At(current_position)`, `append_stream` turns it into a +`Nats-Expected-Last-Subject-Sequence` header, and a mismatch surfaces as a typed +`WrongExpectedVersion`. Creation batches use `NoStream`, which is that same +header carrying `0`. That guard is the whole of the fence: `Any` and +`StreamExists` send no header at all. + +The guard compares a number against the [JetStream](../glossary/jetstream) +sequence of the last message on the session's subject. The comparison is only +meaningful while that number keeps naming the same event. Two operations break +that assumption: + +1. **A physical stream rebuilt or restored to an earlier point.** Sequences are + reissued. A writer holding `At(5)` from before the rebuild can match a + different event that now sits at sequence 5, and the append lands as though + the writer had read current state. +2. **A session's subject emptied.** `subject_current_position` returns `None`, + the guard resolves to `NoStream`, and a redelivered creation command starts a + second history under an identity that already has one. + +Neither is hypothetical in the current design. +[ADR#0035](./0035-session-store-decider-aggregate.md) facet 7 keeps the log +forever, which rules out purging a session subject as an ordinary operation, but +the same facet admits cold-storage tiering that evicts already-immutable events +from the hot stream and restores them on demand. Eviction is the second case +exactly. Disaster recovery is the first. And +[ADR#0013](./0013-origin-stream-sequence-header.md) already contemplates a +restore path that re-appends archived events into a replacement stream, where +every sequence is new by construction. + +The maintenance contract added for schema migration and salvage +([Session Maintenance](../architecture/session-maintenance.md)) made the gap +concrete: `StreamBoundary` carries an optional `incarnation` field and +`IndeterminateReason` carries `SOURCE_INCARNATION_CHANGED`, both of which are +unusable until something defines what an incarnation is and how a writer is kept +out of the wrong one. + +The constraint that shapes every option is that JetStream offers exactly one +server-side guard per publish, and facet 2 has already spent it. Anything else a +writer checks is checked in a separate round trip, before the append rather than +with it. + +## Decision + +### 1. A live session subject's messages are never removed + +No command, repair, operator action, or storage policy deletes, purges, or +evicts messages from the subject of a session that still exists. This is facet 7 +stated as a rule about storage rather than as a consequence about semantics, and +it is what makes case 2 above unreachable: a subject that is never emptied never +resolves to `NoStream` for a session that already has a history. + +The [session doctor](../architecture/session-doctor.md) already respects this. +Every `RepairAction` operates on derived state, and none of them reach the event +stream. + +**This amends [ADR#0035](./0035-session-store-decider-aggregate.md)'s +cold-storage tiering bullet.** Eviction from a live subject is no longer +admissible in any form, because a partially evicted subject and a fully evicted +one produce the stale-guard and false-`NoStream` failures respectively. A +deployment that must bound the hot stream rebuilds into a new incarnation under +rule 2; it does not edit the one it is running on. + +### 2. An incarnation belongs to the physical stream, never to one session + +A **stream incarnation** is a label on the physical JetStream stream that holds +session events. It advances when, and only when, the platform rebuilds that +stream: a restore that does not preserve sequences, a disaster-recovery rebuild, +or a fleet schema migration. It never advances for a single session, because a +per-session incarnation would need a per-session fence and the only atomic +per-subject guard is already spoken for. + +Every session in an incarnation moves to the next one together. A rebuild is a +fleet operation by definition, not an operation with fleet-wide side effects. + +### 3. The incarnation is a subject token, and the fence is the subject + +The incarnation appears as a token in the stream-owned prefix of the session +event subject, so incarnation `i1` and incarnation `i2` occupy disjoint subject +spaces and are bound by different physical streams: + +``` +sessions.i1.events.{session_id} bound by SESSION_EVENTS_I1 +sessions.i2.events.{session_id} bound by SESSION_EVENTS_I2 +``` + +`append_stream` publishes by subject. A writer that resolved its subject under +`i1` publishes to `i1` no matter what it believes about sequences, so its guard +is evaluated against the incarnation it actually read. It cannot reach `i2`, and +no number it holds can be made to match there. + +This is what a checked incarnation token cannot give. Reading a token and then +publishing is two operations, and the rebuild can land between them. Putting the +incarnation in the address makes the check unnecessary rather than making it +faster: a message cannot be published to the wrong incarnation and simultaneously +appear in the right one. + +### 4. Retiring an incarnation means sealing it + +When a rebuild completes, the retired stream is sealed. JetStream sealing is +permanent and rejects every publish, delete, and purge for the life of the +stream. It cannot be lifted. + +Sealing is what turns silent harmlessness into a loud failure. Without it, a +stale writer's append succeeds into a stream nobody reads, and the writer +believes it wrote. With it, the append fails at the server, and the writer +learns it is holding a subject that no longer accepts writes. + +Irreversibility is the point. A fence an operator can lower under pressure is +not a fence, and the pressure to lower it arrives during exactly the incident +that produced the rebuild. + +### 5. The ordinal is the only position that crosses an incarnation + +`SessionOrdinal` is fold-derived from a session's own events, so it survives a +rebuild that preserves those events in order, which the migration contract +already requires as an admissibility rule. Stream sequences do not survive. + +Everything that names a position from outside the stream already uses ordinals: +a fork's `context_prefix_boundary`, checkpoint evidence, `ConsistencyToken`, +`PageCursor`. Those references keep their meaning across a rebuild. Nothing else +does, which is why sequences stay confined to optimistic concurrency and +read-side checkpoints, and why +[ADR#0013](./0013-origin-stream-sequence-header.md) keeps +`Trogon-Origin-Stream-Sequence` to provenance. + +### 6. Derived state does not cross an incarnation boundary + +Projection checkpoints, snapshots, and materialized read models are scoped to the +incarnation whose sequences they cite, and are rebuilt after a rebuild. + +A checkpoint from a retired incarnation is not stale. It is not applicable, and +applicability is decided by comparing incarnation labels rather than by comparing +sequence numbers, because the numbers are comparable and wrong. That is the whole +hazard restated on the read side: two positions from different incarnations +compare cleanly and mean nothing. + +### 7. A session lost to a rebuild is salvaged, not recreated + +If a lossy restore drops a session entirely, its subject in the new incarnation +is empty, `NoStream` succeeds, and a creation command mints a fresh history under +an identity that once meant something else. + +That is data loss showing through, not a fencing failure, and no guard can +distinguish it from a legitimate first creation. The honest handling is salvage: +copy what can still be read into a new identity and mark it as a copy, per the +maintenance contract. Reusing the identity is the one case where requiring a new +Session identity is right, and it is right because the content is gone, not +because the stream was rebuilt. + +### 8. `StreamBoundary.incarnation` becomes required + +The field exists to keep a boundary computed in one incarnation from being +compared against a boundary in another. A migration's source boundary names the +retiring incarnation and its expected target names the new one, and +`INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED` fires when the source has moved +somewhere the intent did not anticipate. An unset incarnation is not "the same +incarnation", so leaving it optional leaves the comparison unable to fail. + +## Alternatives Considered + +### A stream-incarnation token checked with every invariant-bearing command + +Rejected on atomicity. JetStream exposes one server-side guard per publish and +facet 2 spent it on `Nats-Expected-Last-Subject-Sequence`. A separately checked +token is a read followed by a write, so a rebuild that lands between them leaves +the append proceeding on a token that was true when it was read. That narrows the +race rather than closing it, and a fence that narrows a race is not a fence. + +It also charges every invariant-bearing command an extra round trip forever, to +guard against an event that happens at most once per disaster. + +### Prohibit stream recreation and require a new Session identity + +Adopted for a session whose content was actually lost (rule 7), rejected as the +general rule. A disaster-recovery rebuild that preserves every event would, under +a literal reading, invalidate every session identity in the store: every fork +boundary, every stored `context_prefix_boundary`, every external reference held +by a client. That converts a recoverable outage into a total identity reset, and +it does so in the case where nothing was lost. + +Identity should change when content changed. It should not change because the +bytes moved. + +### Make restore preserve an independently verified incarnation identity + +Adopted in substance, rejected in mechanism. Preserving an incarnation identity +across a restore is right, and rules 2 and 3 do it. Verifying it is where the +option fails, for the same reason the checked token fails: verification is a +separate operation from the append it is meant to protect. Carrying the identity +in the subject removes the need to verify anything. + +### Start the rebuilt stream above every sequence the retired one issued + +JetStream lets a stream be created with a starting sequence, so a rebuild could +begin above the retired stream's last sequence and defeat every stale `At(N)`. + +Rejected as insufficient alone. It does nothing about `NoStream`, which carries +`0` and succeeds on any subject the rebuild left empty, which is precisely the +set of sessions a lossy restore dropped. It also keeps both incarnations in one +subject space, so nothing structural stops an old writer from reaching the live +stream. Once the subject spaces are disjoint the sequence spaces are independent +anyway, so the mechanism buys nothing on top of rules 3 and 4. + +### Record the incarnation on each event and let the doctor report mixed streams + +Rejected as a primary mechanism, because the requirement is to fence a writer +out, and detection reports damage after it lands. + +It is also unnecessary. With the incarnation in the subject, a stream containing +events from two incarnations is unrepresentable, so there is no header to record +and no finding to raise. Self-evidencing beats attested, and this is the main +reason to prefer the subject over a field. + +### A per-session incarnation + +Rejected. It would need a per-session fence, and the atomic per-subject guard is +taken. Nothing in the design produces one either: rule 1 forbids removing a live +session's messages, so a single session's sequence space cannot restart while the +stream around it stays put. + +## Consequences + +- The fence is enforced by the server, atomically, on the operation it protects. + A stale writer fails on its next append rather than on a check it might skip. +- The hot path is unchanged. No command pays for an incarnation check, because + there is no incarnation check. +- Sealing cannot be undone, so an operator cannot restore write access to a + retired incarnation during an incident. Recovering something from a retired + incarnation means reading it and salvaging forward. +- A rebuild cannot be scoped to one session. The cheapest remedy for a single + corrupt session is salvage, not a rebuild, which is the outcome the + maintenance contract already assumes. +- Every projection, snapshot, and checkpoint is rebuilt after an incarnation + change, so recovery cost scales with the whole store rather than with the + damage. The doctor's existing `RESET_PROJECTION_CHECKPOINT` and + `REBUILD_PROJECTION` actions cover the per-session case; the fleet case is an + operational procedure that does not exist yet. +- Retired incarnations are retained, because facet 7 does not let events leave + the log and sealing frees no bytes. Storage grows by roughly one full copy per + rebuild. That is a cost keep-forever already accepts, stated rather than + discovered. +- Anything that caches a resolved subject across a rebuild fails loudly. Writers + must re-resolve the subject rather than retry the append, because a sealed + stream rejects retries forever. +- [ADR#0035](./0035-session-store-decider-aggregate.md)'s cold-storage tiering + bullet is amended by rule 1 and is now reachable only as a rebuild. +- `StreamBoundary.incarnation` moves from optional to required, which is a + presence change inside `v1alpha1` and wire-compatible. + +## References + +- [ADR#0013: Origin Stream Sequence Header](./0013-origin-stream-sequence-header.md) +- [ADR#0024: Agent Platform Stream Topology](./0024-agent-platform-stream-topology.md) +- [ADR#0029: Decider Retention and Truncation Watermark](./0029-decider-retention-and-truncation-watermark.md) +- [ADR#0035: Session Store as a Decider Aggregate on NATS JetStream](./0035-session-store-decider-aggregate.md) +- [Session Aggregate](../architecture/session-aggregate.md) +- [Session Doctor](../architecture/session-doctor.md) +- [Session Maintenance](../architecture/session-maintenance.md) diff --git a/docs/adr/0060-session-query-contract-separate-from-projection.md b/docs/adr/0060-session-query-contract-separate-from-projection.md new file mode 100644 index 0000000000..0a2eae7618 --- /dev/null +++ b/docs/adr/0060-session-query-contract-separate-from-projection.md @@ -0,0 +1,167 @@ +--- +number: "0060" +slug: session-query-contract-separate-from-projection +status: draft +date: 2026-08-22 +--- + +# ADR#0060: The Session Read Contract Is a Query Proto, Not the Projection Value + +## Context + +[ADR#0035](./0035-session-store-decider-aggregate.md) facet 8 settles that no +read model is authoritative: listing, search, and summaries are rebuildable +projections folded from the log, checkpointed by stream position, and discardable +at any time. That part is not in question and this ADR does not touch it. + +One sentence inside that facet goes further. It says queries are `verb + noun` +Rust functions over the KV projection +([ADR#0014](./0014-command-and-query-naming.md)) "with no query protos, since the +projection value is the read contract." + +That sentence is wrong, and the Session query work on branch +`yordis/study-vercel-fx` contradicts it directly: twelve protos now exist under +`proto/trogonai/session/sessions/queries/v1alpha1`, defining request and response +shapes, a typed error taxonomy, an opaque page cursor, freshness metadata, and +read-model value types redefined locally rather than imported from the write +side. + +An accepted ADR should not be contradicted by a merged branch without a +correction on the record, and the correction is not a documentation page. It is a +reversal of a decision. + +## Decision + +### 1. The projection value is not the read contract + +A projection and a public contract have opposite obligations, and no single type +can carry both. + +A projection exists to be cheaply rebuilt. Its value type should change whenever +the fold changes, whenever a new field is worth denormalizing, whenever a query +turns out to need something it did not before. The cost of changing it is one +rebuild, which facet 8 already budgets for. That cheapness is the whole point of +the design. + +A public contract exists to hold still. Its cost of change is every client that +decoded the old shape, and those clients are not in this repository and do not +deploy on this schedule. + +Making the projection value the contract couples the two. Either the projection +stops changing freely, which removes the property that made it worth rebuilding, +or the contract changes at the projection's cadence, which means it is not a +contract. Facet 8's own framing is the argument against its own sentence: a type +described as discardable cannot also be the thing callers depend on. + +### 2. Read-model value types are redefined, never shared with the write side + +The queries package defines its own `SessionSummary`, `SessionLifecycle`, +`TerminalReason`, `TitleSource`, and the rest, rather than importing the event or +state types. + +This is facet 3's sibling-subtree reasoning applied to the read side. The +write-side types change whenever the domain changes, which is often and by +design. A shared type would forward every write-side edit straight to every +client, which is exactly the coupling the local redefinition exists to prevent. +The duplication is the feature: two shapes that are allowed to disagree, with an +explicit mapping between them, beats one shape that cannot evolve on either +schedule. + +### 3. The contract is versioned, and the server clamps rather than reports + +Each request carries the caller's `accepted_contract`. The server renders at no +higher than the caller's minor and elides what the caller cannot decode, rather +than emitting a variant that fails to parse. + +A version only on the response lets a client detect an incompatibility after it +has already failed. That difference matters more here than usual because the repo +generates with `unknown_fields=false`, so unknown fields are dropped on decode +rather than preserved. Nothing round-trips through an older decoder intact, and a +declare-then-clamp handshake is what replaces the tolerance that unknown-field +preservation would otherwise have provided. + +### 4. Queries keep `verb + noun` naming and stay Rust functions + +Nothing about [ADR#0014](./0014-command-and-query-naming.md) changes. +`get_session`, `list_sessions`, and `get_session_history` are still the names, and +the handlers are still Rust functions reading a KV projection. What changes is +that their inputs and outputs are declared types rather than whatever struct the +projector happened to write. + +There are no `service` definitions, matching the rest of this repository: +transport binding is JSON-RPC over NATS +([ADR#0055](./0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](./0056-canonical-jsonrpc-bodies-over-nats.md)). The protos are body +types only, so this decision adds a contract without adding a transport. + +### 5. Facet 8's remaining substance is unchanged + +No read model is authoritative. Projections are folded from the log, +checkpointed by stream position, and rebuildable. The context compiler is a +projection. Search is a separate projection. Resume loads a snapshot and replays +the tail. All of that stands exactly as accepted. + +Only the clause "with no query protos, since the projection value is the read +contract" is withdrawn. + +## Alternatives Considered + +### Keep facet 8 as written and expose the projection value + +This is the accepted position, and it is workable right up to the first external +consumer. It fails at the moment a projection needs a field the contract should +not have, or the contract needs a guarantee the projection cannot give, and both +happen early. Freshness is the clearest case: a caller has to be able to tell a +current answer from a lagging one, and that is a fact about the read *path*, not +a field the fold would ever produce. + +### Publish the projection value and version it in place + +Versioning the projection value gives the contract stability without a second +type, at the cost of making every projection change a compatibility event. That +inverts the economics facet 8 established. A rebuildable read model whose shape is +frozen by external clients is no longer rebuildable in the sense that mattered. + +### Define the contract in Rust rather than protobuf + +A Rust type with serde would serve in-process callers. It would not serve a +cross-language client, it would not participate in `buf breaking`, and it would +put the compatibility rules in review comments rather than in a checkable +artifact. The repository already generates every other boundary from protobuf, +and a read contract is a boundary. + +### Amend facet 8 in place rather than by a new ADR + +Editing the sentence out of an accepted ADR would leave no record that the +decision was reversed or why, which is the failure ADRs exist to prevent. The +reciprocal amendment on facet 8 points here, the way facet 7's points to +[ADR#0059](./0059-session-stream-incarnation-fencing.md). + +## Consequences + +- Query protos are additive to facet 8, not a replacement for it. The projection + layer it describes is still what the handlers read. +- The queries package can evolve on its own schedule under `buf breaking`, and a + projection change no longer implies a client change. +- Two shapes now describe overlapping facts, and the mapping between them is + code someone has to maintain. That is the accepted cost, and it is smaller than + the coupling it removes. +- `v1alpha1` is honest and stays there: the contract cannot promote to `v1` + before the projections it reads exist. +- The numeric JSON-RPC error-code reservation for the query error taxonomy is + still open, and is reserved by decision rather than invented in a proto file, as + [ADR#0017](./0017-aauth-agent-authentication.md) did for `-32118`. +- Nothing in this ADR is implemented. The protos exist; the handlers and the + projections they read do not. + +## References + +- [ADR#0014: Command and Query Naming](./0014-command-and-query-naming.md) +- [ADR#0017: AAuth Agent Authentication](./0017-aauth-agent-authentication.md) +- [ADR#0035: Session Store as a Decider Aggregate on NATS JetStream](./0035-session-store-decider-aggregate.md) +- [ADR#0055: NATS Subject Design and JSON-RPC Bindings](./0055-nats-subject-design-jsonrpc-bindings.md) +- [ADR#0056: Canonical JSON-RPC Bodies over NATS](./0056-canonical-jsonrpc-bodies-over-nats.md) +- [ADR#0059: Stream Incarnation Fencing by Subject Isolation and Sealing](./0059-session-stream-incarnation-fencing.md) +- [Session Query Contract](../architecture/session-queries.md) +- [Session Pagination](../architecture/session-pagination.md) +- [Session Projection Freshness](../architecture/session-projection-freshness.md) diff --git a/docs/adr/index.md b/docs/adr/index.md index b5a9bcaa6b..22a4801d36 100644 --- a/docs/adr/index.md +++ b/docs/adr/index.md @@ -64,3 +64,5 @@ future implementation work. - [ADR#0056: Canonical JSON-RPC Bodies over NATS (Draft)](./0056-canonical-jsonrpc-bodies-over-nats.md) - [ADR#0057: Decider Command NATS Binding (Draft)](./0057-decider-command-nats-binding.md) - [ADR#0058: Decider Module Distribution (Draft)](./0058-decider-module-distribution.md) +- [ADR#0059: Stream Incarnation Fencing by Subject Isolation and Sealing (Draft)](./0059-session-stream-incarnation-fencing.md) +- [ADR#0060: The Session Read Contract Is a Query Proto, Not the Projection Value (Draft)](./0060-session-query-contract-separate-from-projection.md) diff --git a/docs/architecture/session-aggregate.md b/docs/architecture/session-aggregate.md new file mode 100644 index 0000000000..fe98a9a85c --- /dev/null +++ b/docs/architecture/session-aggregate.md @@ -0,0 +1,266 @@ +# Session Aggregate + +The [Session](../glossary/session) aggregate is the write side of the Session +Store: one event-sourced stream per session, one fold that turns that stream +into decision state, and one command per transition. This page documents the +wire contract that exists today, which is protobuf only. The Rust +[decider](../glossary/decider) is not implemented yet, and the last section says +exactly what it is waiting on. + +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) is the decision this +implements; [ADR#0045](../adr/0045-event-sourced-service-module-layout.md) is the +layout it follows. Read [Decider](./decider.md) first for the +`decide`/`evolve`/`initial_state` cycle these types plug into. + +## Shape of the contract + +Three kinds of protobuf message live under +`proto/trogonai/session/sessions/`, and confusing them is the most common way to +get this wrong: + +| Kind | Location | Role | +| --- | --- | --- | +| Events | `v1alpha1/*.proto`, past participle (`SessionStarted`, `ToolCallCompleted`) | recorded facts, the only durable truth | +| Commands | `v1alpha1/*.proto`, present tense (`CreateSession`, `StartToolCall`) | untrusted requests, validated then discarded | +| State | `state/v1alpha1/state.proto` | the fold's output, and the aggregate snapshot payload | + +Commands are separate wire messages from events on purpose. An event is a fact +the system has committed to; a command is a request that may be rejected, +duplicated, or malformed. Sharing one message between the two would make the +type system stop distinguishing them. + +`State` doubles as the aggregate snapshot payload, tagged by its own +`buffa::MessageName::FULL_NAME`, following the scheduler precedent. No separate +snapshot proto exists or is needed. + +## What state holds, and what it refuses to hold + +`State` carries exactly the facts some command reads to enforce an invariant. +That is the whole selection rule, and it is why the message is much smaller than +a session transcript: + +- session lifecycle: `state` (missing, active, terminal), `terminal_marker`, + `session_id`, `position`, `execution_plan_digest` +- history shape: `fork_origin`, `keep_through` (newest rewind boundary), + `compaction` (newest marker) +- lineage: `parent`, `delegations` +- attempts: `active_attempt`, `last_attempt_id`, `last_attempt_number` +- reconciliation surfaces: `tool_calls`, `operations`, `checkpoints` +- privacy dependencies: `redacted_event_ids`, `erased_artifact_ids` + +Deliberately absent: message bodies, todo items, artifact lists, display name, +archived flag, assistant-message entries. Every one of those is real session +data, and none of it is read by any command, so all of it belongs to a +projection. Putting it in `State` would mean every replay pays to rebuild a +transcript in order to answer a yes-or-no question. + +`position` is a `SessionOrdinal`: the session's own 1-indexed, fold-derived +position, never a JetStream sequence. Domain references point at ordinals so +that history references survive anything the transport does to sequence numbers. + +Rewind is the clearest case of the state proto encoding a policy. `keep_through` +masks effective history for readers and future turns, but it never un-applies a +folded fact. A tool call that really ran still has to be reconcilable after a +rewind, so its ledger entry stays. + +## Preconditions + +Each command declares which concurrency guard its append runs under. All 42 rows +of [ADR#0035](../adr/0035-session-store-decider-aggregate.md)'s matrix fall into +three classes: + +| Class | Count | Meaning | +| --- | --- | --- | +| `NoStream` | 4 | creation batches: `CreateSession`, `ForkSession`, `CreateChildSession`, `RecoverSession`. A redelivered create observes the stream already exists rather than forking a second history. | +| `At` | 22 | invariant-bearing transitions. The append is guarded against the exact position the decision was made from. | +| `Any` | 16 | commuting happened-facts. No invariant a concurrent writer could break, so no guard. | + +`RecoverSession` is the fourth creation batch and the only one whose precondition +is load-bearing for an operator workflow rather than for a user action: a +salvage derives its target session id before writing, so a retried salvage lands +on the same stream and `NoStream` turns the duplicate into a visible conflict +instead of a second copy. See [Session Maintenance](./session-maintenance.md). + +`StreamExists` is never used. + +`At` needs no trait-level support, and asking for it would be a mistake. +`CommandExecution` already falls back to `At(current_position)` whenever the +stream is non-empty and neither the decider nor the caller declared a +precondition, so a command gets real optimistic concurrency by leaving +`WRITE_PRECONDITION` unset. +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) rejects a trait-level +`At(N)` variant precisely because a compile-time `const` could only weaken that +default, never strengthen it. + +`Any` is a claim about commutativity, and it is only honest because the fold +rules below make ordering irrelevant for those events. + +## Fold rules that make `Any` safe + +Sixteen commands append without a guard, which means two writers can interleave. +Order-independence is bought by five rules in `evolve`: + +- **First terminal outcome wins, per entity.** `ToolCallCompleted` and + `ToolCallFailed` compete on `tool_execution_id`; `AssistantMessageCompleted` + and `AssistantMessageFailed` compete on `message_id`. The first in fold order + is authoritative. A later conflicting outcome stays on the log and is surfaced + by a projection flag, never folded. +- **Orphans fold as unjoined.** A start with no matching request, an outcome + with no matching start: retained, flagged, and changing no entity state. They + are not refused, because refusing them would discard a fact that happened. +- **Highest revision wins.** `TodoUpdated` carries a monotonic `revision` from a + single logical writer; the fold keeps the highest, ties resolving to the first + in fold order. Keeping the highest rather than the latest is what makes it + order-independent. +- **First checkpoint evidence wins,** per `checkpoint_id`. A later event reusing + the id never replaces admitted evidence, so a restore always resolves to the + same bytes. +- **Post-terminal facts are retained but audit-only,** with one carve-out: + guarded ledger and lineage facts still fold after a terminal marker, so an + in-flight side effect stays reconcilable. + +That carve-out is load-bearing. Without it, cancelling a session would strand +every operation still in flight, because the fact that settles them could no +longer be recorded. + +## The operation ledger + +External side effects are guarded by a ledger, not by hope: + +``` +ReserveOperation -> OperationReserved + {operation_id, request_digest, operation_kind} + +RecordOperationOutcome -> OperationOutcomeRecorded + oneof { succeeded | failed | cancelled | unknown } + +RequestOperationCancellation -> OperationCancellationRequested +``` + +Reservation happens before the side effect runs and records a digest of the +request it is reserved for, so a retry arriving with different bytes under the +same id is refused rather than executed as if it were the same call. + +`unknown` is the status that makes crash recovery honest. It means the side +effect may or may not have run, it is explicitly non-terminal, and it may be +superseded exactly once by a determinate outcome. Collapsing it into "failed" +would assert something nobody knows. + +Cancellation is a request, not a settlement. `cancellation_requested` is a +separate flag from `status`; the operation still needs a recorded outcome before +it leaves the ledger. + +## Worked example: a runner that dies mid-tool-call + +This is the case the whole design is shaped around. A runner appends +`ToolCallStarted`, begins the side effect, and the process dies before any +terminal outcome is recorded. + +Replaying the session yields: + +``` +ToolCall { + tool_call_id: "...", + tool_execution_id: "...", + status: TOOL_CALL_STATUS_STARTED, + started_at: , // set + settled_at: , // nothing settled it +} + +Operation { + operation_id: "...", + status: OPERATION_STATUS_RESERVED, + settled_at: , +} +``` + +Both facts are readable directly off the fold. A reconciler does not have to +infer the gap from adjacency in fold order, which concurrent `Any` appends make +unsound anyway. It sees a started call with no outcome and a reserved operation +with no outcome, and it can then: + +- finish the call, if the side effect can be confirmed to have completed: + `CompleteToolCall` plus `RecordOperationOutcome{succeeded}` +- reject it, if the side effect can be confirmed not to have run: + `FailToolCall` plus `RecordOperationOutcome{failed}` +- record honest ignorance, if neither can be confirmed: + `RecordOperationOutcome{unknown}`, superseded later when the truth is learned + +`RecordOperationOutcome` remains admissible after the session reaches a terminal +state, so a call stranded by a cancellation is still reconcilable rather than +orphaned. + +The three distinctions doing the work here are: `started_at` set with +`settled_at` unset means interrupted, not failed; `RESERVED` means the side +effect's fate is unknown, not that it did not happen; and `UNKNOWN` is a status +in its own right rather than a synonym for failure. + +## Identity and deduplication + +Commands arrive at least once. Every command carries a caller-supplied +idempotency key, and event ids are derived deterministically as UUIDv5 over the +resolved stream subject, the command type, the command idempotency key, and the +index within the batch. `Nats-Msg-Id` carries the event id, so a redelivery +publishes byte-identical ids and collapses in the duplicate window. + +The command protos carry no idempotency-key field. Where that key structurally +lives is an explicitly open question in +[ADR#0035](../adr/0035-session-store-decider-aggregate.md), and inventing a +field here would prejudge a decision that has not been made. + +What a caller is told when an append is interrupted, and what a retry is then +allowed to do, is the other half of this and lives in +[Session Crash Boundaries](./session-crash-boundaries.md). + +## Effects, faults, and work that outlives its turn + +Four parts of the catalog are argued on their own pages rather than here. + +What a tool call did beyond returning a result, which covers namespace access as +distinct from content access, copy provenance, and partial outcomes across +multiple targets, is [Session Tool Effects](./session-tool-effects.md). + +A tool call that returns a handle while its work keeps running past the turn is +[Session Detached Work](./session-detached-work.md). + +A provider emission that was shaped like a tool call and could not become one is +[Session Provider Faults](./session-provider-faults.md). + +Three things proposed for this catalog and deliberately kept out of it, with the +condition that would reverse each, are in +[Session Schema Boundaries](./session-schema-boundaries.md). + +## Status and what it is waiting on + +Shipped: `state/v1alpha1/state.proto` and 42 command protos, lint-clean, +formatted, building, and generating Rust bindings. + +Not shipped: `initial_state`, `evolve`, `decide`, the command handlers, +projections, snapshots, the query service, and the recovery operator. + +The Rust runtime is blocked on three shared-crate obligations that +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) raises as requests to +the decider platform, not decisions it can make alone: + +1. **Evolve-visible event identity**, on both the native and WASM replay paths. + `ApplyRedaction` guards that its targeted event ids exist in-session, and that + is uncheckable from folded state while `evolve` cannot see an event's id. + This would change the near-frozen core `Decider` fold surface for every + business, so whether it belongs there at all is undesigned. +2. **A deterministic id-derivation hook.** The UUIDv5 formula needs the resolved + subject, command type, idempotency key, and batch index. The runtime's + existing `EventIdentity::event_id` override point sees only the event, so it + cannot host this. +3. **Duplicate-publish-ack treated as success** rather than an append error. + This first requires the canonical command digest to be recoverable at the ack, + otherwise the append path cannot tell an idempotent retry from key reuse with + different content. + +Separately, shared multi-tenant deployment is blocked on +[ADR#0027](../adr/0027-decider-multi-tenancy-primitive.md)'s resolver contract. +No `tenant_id` is added speculatively ahead of it; until it lands, a session is +scoped by its subject alone. + +The `v1alpha1` suffix is an honest signal rather than a placeholder. It becomes +`v1` when those obligations are met and the draft ADRs this contract depends on +are accepted. diff --git a/docs/architecture/session-artifacts.md b/docs/architecture/session-artifacts.md new file mode 100644 index 0000000000..b93cda50f7 --- /dev/null +++ b/docs/architecture/session-artifacts.md @@ -0,0 +1,267 @@ +# Session Artifacts + +A command produces 40 MB of output. The session log records a claim-check to it +and never the bytes. This page documents how a caller gets part of those bytes +without pulling all of them, how it establishes that what it got is what the log +promised, and what it is told when the bytes are not there. It documents the +protobuf contract that exists today. There is no Rust implementation yet. + +See [Session Aggregate](./session-aggregate.md) for how artifacts are recorded, +[Session Doctor](./session-doctor.md) for the check that probes the artifact +store, [Session Query Contract](./session-queries.md) for the read model this +extends, and [Session Terminal Replay](./session-terminal-replay.md) for the +artifact class that leans hardest on range reads. + +## A whole-artifact digest cannot check part of an artifact + +`ArtifactRef.digest` covers every byte. It is the claim-check key and the +content-addressing key, and checking anything against it means hashing 40 MB. +That is the exact cost a range read exists to avoid, so a caller fetching 64 KB +has two options: pay the full cost anyway, or skip the check while still holding +a digest that looks like it proved something. The second is what actually +happens. + +So an artifact is also hashed in fixed-size chunks, and the digest of that +ordered chunk-digest list is recorded on the log by `ArtifactRecorded`, in +`StoredArtifact.chunks`. Verification then has three steps, and the order of +them is the whole design: + +1. The caller reads `ContentChunks.manifest_digest` from the session's own + history. This value came from the event log. +2. The caller fetches the chunk manifest, hashes it, and compares. This is the + step that matters, because the manifest comes from the artifact store and a + store serving wrong bytes will happily serve a manifest that agrees with + them. Compared against the log, it cannot. +3. The caller hashes the chunks it received and compares them to the manifest it + just established. Cost is proportional to what it read, not to the artifact. + +Trust flows outward from the log. A manifest checked only against the store that +served it proves that the store is self-consistent, which is a property a +corrupted store also has. + +The chunk count is deliberately not recorded next to the chunk size: it follows +from `StoredArtifact.size_bytes`, and a second field carrying a derivable fact +is a second field that can disagree with the first. + +## The server does not verify, and does not claim to + +`ReadArtifactRangeResponse` reports `RangeVerifiability`, not a verification +result. There is no field on it meaning "verified". + +A server field saying "verified" would be the party under suspicion certifying +itself. The reason to check an artifact at all is that the store might return +the wrong bytes, and a store that returns the wrong bytes will also set a +boolean to true. The only check worth anything is one the caller performs +against a value the store did not supply. + +That fixes this contract's obligation, and it is a narrower one than it looks: +serve ranges in a shape the caller can check, and say plainly when it has not. +`RANGE_VERIFIABILITY_VERIFIABLE` means the served range covers whole chunks, so +every byte in it falls under a chunk digest. `NO_MANIFEST` means the artifact +was stored without chunk hashing and nothing short of a full read can check it. +`RANGE_NOT_ALIGNED` means a manifest exists and the caller asked for bytes that +do not line up with it, so the partial chunks at the edges are uncovered. + +Verified reads are therefore chunk-granular. A request for bytes 100 through 200 +of a 1 MB-chunked artifact is served as the whole first chunk, and the response +says so. Which is why the response reports the offset actually served rather +than echoing the request: a caller that assumes it received what it asked for +will misread the buffer by 100 bytes, and it will misread it silently. + +## Requiring verification means refusing, not warning + +`VerificationRequirement` defaults to required when unset. + +The default has to be the strict one. A caller that never thought about +verification is exactly the caller who will not notice unchecked bytes arriving, +and a field whose omission quietly weakens a guarantee is a guarantee only for +people who read the schema. + +And when the requirement cannot be met, the read fails with +`ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE` rather than returning bytes +labelled unverifiable. A requirement that degrades into a label when it cannot +be satisfied is not a requirement. The caller asked not to receive unchecked +bytes; handing them over with a note attached is delivering the thing they asked +to avoid, and doing it in a field they have no reason to read. + +`NOT_REQUIRED` is a real option and belongs to a preview pane. It does not +belong to anything that will be executed, replayed, or stored elsewhere as the +artifact. + +## The response says where it is, so nothing has to say whether it is done + +`ReadArtifactRangeResponse` carries the served offset, the served bytes, and the +artifact's total size. It carries no `truncated` or `eof` flag, and no separate +length field. + +Length is the length of `content`; a second copy of it is a value that can +disagree with the bytes next to it, and the copy is the one a caller would +trust. End-of-artifact follows from `offset + len(content) == size_bytes`; a +flag would be a second answer to a question the numbers already settle. Being +cut short by a server cap is the same comparison coming out the other way. A +caller resuming a sequential read knows where to resume without asking again. + +This is the same reason `WriteOutcome` derives disposition from state rather +than carrying it: two fields for one fact can disagree, and the one that +disagrees is the one a caller trusted. + +## Statting an artifact cannot fetch it + +`StatArtifactRequest` has a session id and an artifact id. It has no range, no +"include content", and no size threshold under which the bytes come along. + +The structural argument is the one that gives `DiagnoseSession` no repair mode. +A caller asking what a 40 MB artifact is must not be able to fetch 40 MB by +setting a field wrong, and a reviewer must not have to read a runtime value to +know a call was cheap. + +`StatArtifactResponse` also carries the recorded preview, which is on the log +rather than in the artifact store. So it survives the bytes: an erased artifact +still previews. For a great many callers the preview is the whole answer, and +the reason it is not modelled as a range read is that it costs nothing to serve. + +`ReadableContent` is set only for an available artifact. A size and digest +reported next to `ERASED` would be describing something the caller cannot +obtain. + +## Absence has kinds, and they are not interchangeable + +`ArtifactAvailability` does not have a "missing" value that covers everything +that is not the bytes. Collapsing them is how deliberate destruction gets +reported as data loss. + +- `ERASED`: destroyed on purpose and recorded by `ArtifactErased`. The + claim-check and its provenance stay on the log. This is a correct end state, + and a reader that renders it as damage sends someone looking for a problem + that was the point. +- `MISSING`: the store has no object and no erasure was ever recorded. This is + the one value that means something went wrong. The log says bytes exist that + do not. +- `EXTERNAL_ONLY`: recorded as an external reference whose bytes were never + durably stored. Nothing was lost; nothing was ever held. +- `CORRUPT`: read, and does not match the recorded digest. Serving these bytes + quietly would hand a caller content under a claim-check it does not satisfy. +- `UNREADABLE`: could not be read, which makes no claim about whether the bytes + exist. A permissions or transport fault against the artifact store looks + identical from here and a retry may succeed. Reported as `MISSING` it sends an + operator after a backup instead of a broken credential. +- `HIDDEN`: the caller may see that the artifact exists and may not read it. + +The first five reuse the doctor's existing mismatch, absent, and unreadable +distinction rather than inventing a second vocabulary for the same three facts. + +`HIDDEN` is the one that needs defending, because elsewhere in this system +authorization hides existence: `QUERY_ERROR_CODE_SESSION_NOT_FOUND` deliberately +does not distinguish a missing session from a forbidden one, so that probing +cannot use the difference to prove a session exists. The difference here is that +by the time an artifact id can be named, the caller is already reading a session +whose history contains the claim-check. The reference is visible; only the +content is withheld. Answering `MISSING` would not conceal anything, it would +just describe the session incorrectly, and it would say bytes were lost when +they were not. An artifact inside a session the caller cannot see is never +reachable to be labelled at all. + +Every one of these rides on a successful response. `ArtifactError` is for +failures to answer, so that "what happened to this artifact" stays +distinguishable from "the read contract is broken" at the moment an operator +needs to tell them apart. The one pair worth reading twice: +`ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND` means the session holds no claim-check +under that id, so nothing was ever promised; `ARTIFACT_AVAILABILITY_MISSING` +means the log made a promise the store did not keep. + +## Successive ranges are the streaming primitive + +There are no `service` definitions anywhere in `proto/`. Transport is JSON-RPC +over NATS ([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)) and the protos are body +types, so there is no streaming call to bind to. A caller reading 40 MB issues +successive bounded ranges. + +Stating this is better than inventing a streaming RPC that nothing implements. +It also has a property worth keeping: the bound is always the caller's and +always visible in the request, rather than a limit discovered when a response +fails to fit. A server cap is still possible and is reported through +`ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE`, whose accepted maximum is carried in the +message because it is deployment-specific rather than a schema constant. + +## Completeness is not lifecycle + +`SessionView.artifacts` reports how much of a session's artifact content is +still retrievable, separately from whether the session succeeded. + +The two are independent and routinely disagree. A session can close having done +exactly what was asked and still be missing the output it produced, because +artifact bytes live outside the log: they get erased under a retention policy, +under a deletion request, or by a storage fault. A reader that infers +retrievability from `TERMINAL_REASON_CLOSED` will present an empty result as a +successful one. + +`ArtifactCompletenessView` counts only what the log itself establishes: +recorded, claimed retrievable, erased, external-only, and hidden from this +caller. Whether the bytes behind an intact claim-check are actually present is a +fact about an external store, and learning it costs one probe per artifact, +which is not something a query can do and remain a query. + +That answer arrives through `observed`, set only when someone has actually +looked. Unset means nobody has, which is not the same as nothing being wrong, +and the field is absent rather than zeroed precisely so the two cannot be +confused. `ObservedIntegrityView` carries `missing`, `digest_mismatch`, and +`unreadable`, and an `observed_at`, because these counts describe a store at an +instant and an artifact can be lost the moment after. A stale all-clear is not a +current one. + +`hidden` is per-caller, so two readers of the same session can see different +totals. Surfacing it is the point: the difference is authorization, not damage. + +The rollup is on `SessionView` and not on `SessionSummary`. Unlike +`RecoveryProvenanceView`, which is on the list row because a picker rendering a +salvaged session identically to an intact one is where a substitution actually +happens, an incomplete artifact view does not change what the session is. It +changes what can be retrieved from it, which is a thing you find out when you +open it. + +## Layout + +The read contract lives in its own sibling subtree, +`trogonai/session/sessions/artifacts/v1alpha1`, alongside `doctor` and +`maintenance`, and redefines its value types locally rather than importing them +from the write side ([ADR#0035](../adr/0035-session-store-decider-aggregate.md) +facet 3). The write side records what happened to an artifact; this contract +answers what a caller can get right now, and the two change for different +reasons on different cadences. + +- `availability.proto`: `ArtifactAvailability`. +- `stat_artifact.proto`: `StatArtifactRequest`, `StatArtifactResponse`, + `ReadableContent`. +- `chunk_manifest.proto`: `GetChunkManifestRequest`, + `GetChunkManifestResponse`. +- `read_artifact_range.proto`: `ReadArtifactRangeRequest`, + `VerificationRequirement`, `ReadArtifactRangeResponse`, `RangeVerifiability`. +- `artifact_error.proto`: `ArtifactError`, `ArtifactErrorCode`. + +The durable half is one message on the write side, +`trogonai/session/sessions/v1alpha1/content_chunks.proto`, held there because it +is recorded by `ArtifactRecorded` on `StoredArtifact.chunks` and a sibling +subtree does not get to define fields on a write-side event. + +A typed, versioned diff is one of the payloads that sits behind a claim-check +rather than in the schema; see +[Session Structured Diff](./session-structured-diff.md). + +## Status + +Shipped: the six protos above and the `SessionView` rollup, lint-clean, +formatted, building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::artifacts_v1alpha1`. + +Not shipped: the artifact store binding, chunk hashing at record time, the range +reader, the availability resolver, the completeness projection, the doctor probe +that fills `observed`, and the transport binding. + +`StoredArtifact.chunks` is optional, and it stays optional. Artifacts recorded +before chunk hashing existed do not have one and cannot retroactively acquire +one from a log that does not contain their bytes, and a small artifact does not +need one. Absence is a first-class answer here rather than a migration to +finish: it means no range of that artifact can be checked, the read contract +says exactly that, and a caller that required verification is refused rather +than quietly served. diff --git a/docs/architecture/session-crash-boundaries.md b/docs/architecture/session-crash-boundaries.md new file mode 100644 index 0000000000..5b224da884 --- /dev/null +++ b/docs/architecture/session-crash-boundaries.md @@ -0,0 +1,230 @@ +# Session Crash Boundaries + +Every place a Session write can be interrupted, what the caller is owed there, +and what a retry is allowed to do. This page is the specification the +crash-boundary tests will assert against. It documents the protobuf contract +that exists today and the derivation rule the contract depends on. There is no +Rust implementation yet, and there are therefore no tests yet. + +See [Session Aggregate](./session-aggregate.md) for the write side and +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 2 for the +optimistic concurrency this builds on. + +## The failure this exists for + +The store accepts an event and the acknowledgment is lost. The writer knows it +published and nothing else. + +Reporting failure is wrong, because the event may be committed and the caller +will act on a lie. Reporting success is wrong for the mirrored reason. Retrying +blindly is wrong because it writes a second copy of a fact that already +happened, and a session log with two `SessionStarted` events is not repairable +by anything downstream of it. + +So the writer has to be told the outcome is unknown, and then be able to resolve +it. `WriteOutcome` is the first half. The identity rule below is the second. + +## Identity is derived, never assigned + +[Session Aggregate](./session-aggregate.md) already fixes the derivation: +UUIDv5 over the resolved stream subject, the command type, the command's +caller-supplied idempotency key, and the index within the batch. `Nats-Msg-Id` +carries the result, so a redelivered command publishes byte-identical ids and +collapses in the duplicate window. + +The choice of terms is what makes a retry safe, and it is worth being precise +about which failures it covers. + +**It keys on the command, not on the event.** A retry does not have to reproduce +the event's bytes, which it could not do anyway: events carry timestamps, so a +regenerated event differs from the one that may already be committed. Deriving +from the command means the retry reproduces the identity without reproducing the +encoding. + +**It covers redelivery of the same command.** Same key, same subject, same +index, same id, so the store recognizes the repeat. That is the lost +acknowledgment case, and it resolves without anything else being true. + +**It does not cover reuse of a key across different commands.** Two different +commands sent under one idempotency key derive the same id, and duplicate +detection keys on identity alone: the second is discarded and acknowledged as a +success. That is silent data loss wearing the shape of idempotency, and no +derivation prevents it, because the caller controls the key. + +Which is why `CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT` is a +reported conflict rather than an unreachable state. It is the direct consequence +of putting a caller-supplied value in the identity, and detecting it is the +price of that choice. + +Two things this depends on do not exist yet. `EventIdentity for SessionEvent` is +the empty default, so the runtime assigns a fresh UUIDv7 per publish: a retry +today produces a different id and duplicate detection does nothing at all. And +the command protos carry no idempotency-key field, because +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) leaves the key's +structural home explicitly open. The derivation is documented and unimplemented +on both ends. + +## Resolving a duplicate acknowledgment + +The store's duplicate acknowledgment carries the sequence of the original +message. Today `append_stream` treats that acknowledgment as an error and +discards the sequence, which turns the one signal that resolves a lost +acknowledgment into a failure. + +A duplicate acknowledgment is not ambiguous. Identity is derived from the +command, so a duplicate means this command's events are already on the log, and +the only thing left to establish is where. The rule is: read the message at the +returned sequence, resolve its `SessionOrdinal`, and report +`WRITE_STATE_DEDUPLICATED` with that ordinal. The read costs nothing on the +happy path, because a duplicate acknowledgment only happens on a retry. + +It is worth being explicit that the store is not the place divergence is caught. +Reuse of one idempotency key across two different commands derives the same id, +and duplicate detection keys on identity alone, so the store would discard the +second command's events and acknowledge success. +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) catches this earlier: +a guarded command re-replays and no-ops on a key the aggregate has already seen, +so the reuse is refused at decide time and nothing is published. +`CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT` reports that refusal, and +it reports it as a refusal, with nothing appended. + +The division matters because the store cannot make this call. A correct retry +that re-enters the decider produces a different encoding of the same decision, +since events carry timestamps, so a store comparing bytes would flag every +command-layer retry as divergence. The aggregate compares keys against +decisions, which is the comparison that actually answers the question. + +## The duplicate-detection window bounds where dedup happens, not whether + +Duplicate detection lives in a per-subject table the server keeps for a +configured window. `DuplicateWindow` is documented in the substrate as an +operational capacity knob rather than a delivery guarantee, and that is the +honest description: it is bounded, and past it the store cannot tell a retry +from a first attempt. + +Past it, dedup moves rather than disappearing. A guarded command's retry +re-replays and no-ops on its idempotency key at the aggregate. An unguarded fact +relies on readers collapsing identical ids. So the window is not the last line +of defense, and a retry that outlives it is not automatically a duplicate on the +log. + +What the window does bound is who can answer. Past it, the store no longer can, +and `UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED` says exactly that: the +outcome is determinable, and not from here. Reporting it as an ordinary timeout +would point a caller at a retry the store can no longer make safe. + +## The boundary matrix + +Each row is a point where the process can stop. `state` is what the caller must +observe. Disposition is derived from the state rather than reported alongside +it, because two fields for one fact can disagree. + +### Append + +| Boundary | State | Retry may | +| --- | --- | --- | +| Rejected before publish (invalid header, invalid event) | `NOT_APPENDED` | retry the command | +| Head guard refused (`WrongExpectedVersion`) | `CONFLICT` / `WRONG_EXPECTED_HEAD` | re-read and decide again, never retry unchanged | +| Creation batch found a non-empty stream | `CONFLICT` / `STREAM_ALREADY_EXISTS` | nothing; the identity is taken | +| Subject belongs to a sealed incarnation | `CONFLICT` / `INCARNATION_RETIRED` | re-resolve the subject, never retry | +| Published, no acknowledgment observed | `UNKNOWN` / `ACK_TIMEOUT` | retry, which commits or deduplicates | +| Acknowledgment arrived unreadable | `UNKNOWN` / `ACK_UNREADABLE` | retry | +| Acknowledged | `COMMITTED` | nothing | +| Duplicate acknowledgment | `DEDUPLICATED` | nothing | +| Idempotency key already seen with a different decision | `CONFLICT` / `IDENTITY_REUSED_WITH_DIFFERENT_CONTENT` | nothing; refused at decide time, nothing published | +| Retry aged past the duplicate window | `UNKNOWN` / `DEDUPLICATION_WINDOW_EXPIRED` | resolve at the aggregate or by reading, not by republishing | + +### Batch + +Creation batches are atomic: `SessionStarted` with its plan and workspace, +`ForkSession`, delegated-child creation, `RecoverSession`. Each writes several +events under one `NoStream` guard. + +| Boundary | State | Retry may | +| --- | --- | --- | +| First member refused by the guard | `CONFLICT` / `STREAM_ALREADY_EXISTS` | nothing | +| Some members acknowledged, some not | `UNKNOWN` / `BATCH_PARTIALLY_ACKNOWLEDGED` | read the stream, never retry the batch | +| Every member acknowledged | `COMMITTED` | nothing | +| Whole batch deduplicated | `DEDUPLICATED` | nothing | + +The partial case is the one worth stating plainly: a stream holding half a +creation batch is a shape no fold expects, and retrying the batch cannot fix it, +because the `NoStream` guard now sees a non-empty stream. It resolves by reading +what is actually there. + +### Side effects around the append + +These boundaries are not about the store. They are about the order the platform +does things in, and each one has exactly one safe order. + +| Boundary | Safe order | Why | +| --- | --- | --- | +| Artifact bytes and the event referencing them | bytes first, event second | an event pointing at bytes that were never written is unrepairable; bytes nobody references are an orphan the doctor can find | +| Event and projection update | event first, projection second | the event is the source of truth and the projection is rebuildable | +| Projector checkpoint and materialized write | write first, checkpoint second | a checkpoint ahead of its view claims work it did not do, which is `FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT`; a checkpoint behind its view replays, which is idempotent | +| Checkpoint artifact upload and `CheckpointProduced` | upload first, event second | same rule as artifacts, and restoration admits a checkpoint only against evidence that is actually readable | +| Migration staging and commit | intent first, target second | see [Session Maintenance](./session-maintenance.md); the intent is what makes a lost commit reconcilable rather than unknown | +| Redaction and dependent projections | event first, propagation second | a mask that propagates before it is durable can be lost, and a mask that is lost is a disclosure | + +The asymmetry in every row is the same one: do the reversible thing first. An +orphaned artifact is findable and releasable. A dangling reference is neither. + +## What the tests must assert + +For each row above: inject the failure at that boundary, and assert the caller +observed exactly the listed state, then that the prescribed retry reaches a +terminal state without producing a second copy of any event. + +Two assertions are worth calling out because they are the ones a passing suite +can most easily fake. + +**No boundary produces best effort.** Every row terminates in `COMMITTED`, +`DEDUPLICATED`, `NOT_APPENDED`, `CONFLICT`, or `UNKNOWN`. A test that accepts an +untyped error at any boundary is asserting that the boundary is unspecified. + +**`UNKNOWN` is asserted as unknown, not as either answer.** The temptation is to +let the test settle the ambiguity by inspecting the stream and asserting what +really happened. That tests the store and not the contract. What the caller was +told is the thing under test, because acting on the wrong half of an unknown is +the failure the whole page exists for. + +## Layout + +`proto/trogonai/session/sessions/v1alpha1/write_outcome.proto`: `WriteOutcome`, +`WriteState`, `IndeterminateWrite`, `UnknownWriteReason`, `WriteConflict`, +`ConflictKind`. + +It sits with the commands rather than in a sibling subtree, because it is not an +operator surface or a read contract. It is the other half of every command: the +answer, in the same package and the same release cadence as the request. + +## Status + +Shipped: the outcome contract above, lint-clean, formatted, building, and +generating Rust bindings. + +Not shipped: the tests, and everything they need. There is no Session runtime, +no command handler, and no NATS adapter for sessions, so there is nothing to +interrupt. Writing the suite against a mock written for the occasion would +assert that the mock behaves the way the mock was written. + +Three implementation gaps are named above rather than left to be rediscovered. + +`EventIdentity for SessionEvent` is the empty default, so the runtime assigns a +fresh UUIDv7 per publish and a retry today produces a different id. Duplicate +detection does nothing, which collapses four rows of the matrix into one +undetected duplicate. + +A duplicate acknowledgment is surfaced as an error and its sequence is +discarded, so the one signal that resolves a lost acknowledgment is thrown away +at the point it arrives. + +The command idempotency key has no structural home, which +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) leaves open +deliberately. Until it does, the derivation has no input and the aggregate's +seen-key horizon has nothing to key on, so both halves of the dedup story are +waiting on the same decision. + +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) already says this +machinery is a substrate obligation rather than a shipped guarantee. This page +is what it has to satisfy. diff --git a/docs/architecture/session-detached-work.md b/docs/architecture/session-detached-work.md new file mode 100644 index 0000000000..dfd6c2ad19 --- /dev/null +++ b/docs/architecture/session-detached-work.md @@ -0,0 +1,117 @@ +# Session Detached Work + +An agent starts a development server. The tool returns a URL, the turn ends, and +the process keeps running and keeps producing output for hours. This page +documents how the session records that the turn was released while the work +continued, and why almost none of that needed new machinery. It documents the +protobuf contract that exists today. There is no Rust implementation yet. + +See [Session Aggregate](./session-aggregate.md) for the operation ledger and +[Session Doctor](./session-doctor.md) for what happens to work nobody is +supervising any more. + +## What was already there + +Detached work looks like it needs a whole subsystem, and it mostly does not, +because the operation ledger was built for exactly this shape. Work whose outcome +arrives later than the call that started it already has: + +- a durable identity, from `OperationReserved` +- a cancellation channel, from `OperationCancellationRequested` +- an outcome that arrives whenever it arrives, from `OperationOutcomeRecorded` +- a way to say the outcome is not knowable, from `OperationUnknown` +- somewhere to put the output, in `CommandOutputReplayRef` +- a reader-visible flag that the session is not finished settling, in + `SessionView.has_unreconciled_work` + +Adding a compound background-turn event on top of that would have restated all of +it in a second vocabulary, and the two would drift. + +## What was actually missing + +Three things, and they are small. + +The first is that the tool call lied. `ToolCallCompleted` means the call +finished, and a reader folds it as done. When the call returned a handle rather +than an outcome, that fold is wrong in a way nothing on the event corrects. +`DetachedWork` on `ToolCallCompleted` says the completion is a handoff: the +result is a handle, and the outcome is in the ledger under `operation_id`. + +The second and third are policies nobody can infer afterwards: what happens to +this work when the session ends, and how long it may go unwatched before someone +should go looking for it. + +## Cancel is the safe default + +`TerminalOwnership` decides what becomes of the work when the session reaches a +terminal state, and its zero value cancels. + +The two failure modes are not symmetric. Cancelling work that should have +survived is loud: something the user wanted running stopped, and they find out +within minutes. Leaving work running that should have stopped is silent, and it +is precisely the orphan problem from +[Session Doctor](./session-doctor.md#orphans-and-why-finding-one-is-not-enough-to-delete-it) +with a process attached instead of a byte range. A default that leans toward the +silent failure is a default that accumulates. + +`TERMINAL_OWNERSHIP_SURVIVE_TERMINAL` is the deliberate opt-in. A session that +ends with surviving detached work is terminal and not complete, which is the +distinction `has_unreconciled_work` exists to carry. + +## The lease policy is an event; the heartbeat is not + +This is the one call worth arguing for, because the obvious design is wrong. + +Supervision looks like something to record. A runner holds the work, renews a +lease every thirty seconds, and if it stops renewing the work is abandoned. It is +tempting to append each renewal, so the history shows exactly when supervision +was lost. + +That is an append per interval into a log that is never truncated +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7), and +long-lived detached work generates the most of them. A server running for eight +hours would contribute nearly a thousand events that no projection folds and no +reader wants, permanently. This is the same fault the analysis flags for a +downstream consumer writing its checkpoint into session streams: liveness is +live state, and live state does not belong in history that outlives it. + +So `SupervisionPolicy` records `max_unsupervised` and the `runner_id` that held +the work, and nothing else. The live lease sits in the runner registry a +projection reads. What the log keeps is the number a reconciler needs *after* the +fact: given how long the work was allowed to go unwatched and when it was last +seen, whether it is lost is a question anyone can answer later without having +been watching. + +That is what makes an expired lease a doctor finding rather than a lost fact. +`ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE` is reachable because the policy is on +the log even though the heartbeat never was. + +## The endpoint has the same rule as every other external URL + +`DetachedWork.endpoint` is where the caller reaches what was started: a URL, a +socket path, a container id. It must be credential-free, which is the prohibition +`ExternalArtifact.source_url` already carries. A detached development server's URL +is, empirically, the field most likely to arrive with a session token stapled to +the query string, into a log that is never truncated. + +## Layout + +`proto/trogonai/session/sessions/v1alpha1/detached_work.proto` + +| Type | What it settles | +| --- | --- | +| `DetachedWork` | the completion is a handle, and where the real outcome lives | +| `TerminalOwnership` | what happens to the work when the session ends | +| `SupervisionPolicy` | how a lost runner becomes detectable, without a heartbeat in the log | + +It attaches at `ToolCallCompleted.detached` and `CompleteToolCall.detached`. + +## Status + +Shipped: `detached_work.proto`, lint-clean, formatted, building, and generating +Rust bindings reachable at `trogonai_proto::session::sessions::v1alpha1`. + +Not shipped: the runner registry that holds live leases, the reconciler that +turns an expired one into a finding, and any enforcement of +`TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL` at session close. The contract names what +must be true; nothing yet makes it true. diff --git a/docs/architecture/session-doctor.md b/docs/architecture/session-doctor.md new file mode 100644 index 0000000000..5494fbaafe --- /dev/null +++ b/docs/architecture/session-doctor.md @@ -0,0 +1,241 @@ +# Session Doctor + +The doctor inspects a session and reports what disagrees with what. Repairs are +a separate operation that can only act on findings from a specific report, and +only on derived state. This page documents the protobuf contract that exists +today. There is no Rust implementation yet. + +See [Session Aggregate](./session-aggregate.md) for the write side and +[Session Projection Freshness](./session-projection-freshness.md) for the +watermarks several checks compare against. + +## Why diagnosis and repair are different operations + +The obvious design is one operation with a `dry_run` flag. It is also the design +that eventually deletes something, because report-only then lives in a field, +and a field can be forgotten, defaulted, or lost in a refactor. + +So `DiagnoseSession` has no mode. It mutates nothing and has no field that could +make it mutate. Reaching a mutation requires calling a different operation with +a different message, which is a thing a caller does on purpose. + +Where a flag is unavoidable, on the repair itself, the numbering carries the +default: `REPAIR_MODE_UNSPECIFIED = 0` is dry run. A caller that forgets the +field, decodes an older message, or misses a branch when building a request gets +a preview. Any other ordering makes the destructive path the default, and a +default that destroys is a defect documentation cannot fix. + +## No repair touches the event stream + +Every value in `RepairAction` operates on derived state: rebuild a projection, +reset a checkpoint, quarantine a generation, discard a snapshot, re-verify an +artifact, release an orphaned claim. + +That is a boundary, not a starting set. The event stream is the source of truth +and it is append-only. A repair that edited or deleted events would make the log +depend on the tooling built to inspect it, and every guarantee resting on replay +determinism would rest instead on nobody having run the wrong repair. + +The corollary catches what operators most expect to find here. A tool call that +started and never recorded an outcome is exactly the kind of thing a doctor +surfaces, and reconciling it is **not** a repair. It is `CompleteToolCall` or +`FailToolCall`, an ordinary command through the ordinary decider, subject to the +ordinary invariants. Routing it through the doctor would let an operator write +history without passing the rules that make the history mean anything. + +This is also why severity is the enum it is. `DEGRADED` means derived state +disagrees with an intact stream, so rebuilding should fix it. `CORRUPT` means +the stream cannot be fully interpreted, so nothing can, and those findings +usually carry no available repairs. That is the honest answer rather than a gap +in the list. + +A `CORRUPT` finding leaves exactly one path forward, and it is not here. +Salvage copies what can still be read into a new session identity, which works +precisely because it does not pretend to repair anything: the damaged source is +left untouched and the copy is marked as a copy. See +[Session Maintenance](./session-maintenance.md). + +## An empty report is not health + +`DiagnoseSessionResponse` carries `checks` alongside `findings`, one entry per +check the server considered, including ones it skipped. + +A doctor that exhausted its budget after two checks returns the same empty +`findings` list as a clean session. An operator reading only `findings` cannot +tell those apart, and the failure mode is the worst available: a diagnostic +that reports health it did not verify, to someone who ran it precisely because +they were worried. + +So an empty `findings` list means healthy only when every entry in `checks` +reports `CHECK_STATUS_COMPLETED`. `BUDGET_EXHAUSTED` says findings so far are +real and their absence proves nothing. `FAILED` says the check itself broke, +reported rather than swallowed. + +The budget exists because inspection is unbounded by nature: verifying every +artifact digest on a long session means reading every artifact. Without a bound +the doctor becomes a load generator operators learn not to run, and a diagnostic +nobody dares use is worth nothing. `CHECK_KIND_ARTIFACT_DIGEST` and +`CHECK_KIND_ORPHAN` are outside the default set for that reason, one because its +cost scales with storage rather than the stream, the other because deciding an +orphan means tracing durable ownership and projector watermarks. + +## Repairing safely + +Three properties, each closing a failure operator tooling reaches for eventually. + +**Targeted.** There is no "repair everything" shape. A caller names exact +findings and the exact action for each. A bulk repair is a repair whose blast +radius nobody reviewed. The action must also be one the finding offered in +`available_repairs`, so what is legal is decided by the code that understands +the finding rather than by the caller. + +**Provenanced.** `diagnosis_id` binds every mutation to the report that +justified it. A repair naming an unknown diagnosis is refused rather than +treated as an unprovenanced repair, and one naming a diagnosis too old to +authorize a mutation fails with `DIAGNOSIS_EXPIRED`. + +**Re-verified.** The server re-runs each finding's check before acting. The +interval between running a doctor and running a repair is where state changes, +and a repair that trusts a ten-minute-old report will discard a projection that +already rebuilt itself. When re-verification finds the problem gone, the result +is `NOT_REPRODUCIBLE`, which is a success: doing nothing was correct. + +`finding_id` is a digest over the finding's kind and subject, not over its +observed values. A projection that fell further behind between diagnosis and +repair is still the same finding, and an id that changed with every observed +byte would make repairs impossible on a busy session. Identity is stable; +staleness is caught by re-verification. + +Results are per target, because a repair call is not atomic and pretending +otherwise would hide which half of it landed. `REFUSED_UNSAFE` is the interesting +status: the finding still holds and the server declined anyway. An unreadable +artifact is the standard case. Unreadable is not the same as absent, it may be a +permissions or transport problem, and nothing that treats it as data loss may +run on that evidence. + +## Orphans, and why finding one is not enough to delete it + +An artifact upload succeeds and the append that would reference it fails. The +bytes are durable, nothing points at them, and nothing ever will. Multiply that +by every crash and every timeout and it becomes a storage bill. + +Cleanup is the dangerous half. The obvious implementation searches for +references, finds none, and deletes. It is wrong for two reasons, and neither +one shows up in testing. + +The first is that a reference search is not an ownership trace. Content-addressed +storage means the same bytes can be reachable through a stream nobody thought to +scan, so "no reference found" is only meaningful alongside where the search ran +and where it stopped. A check that scanned four of a tenant's streams produces +the same empty result as one that scanned all of them. `OwnershipTrace` is what +separates them: streams read, streams that could not be read, the position the +scan covered through, the head at the time, and how far the projectors it +consulted had applied. Any unreadable stream makes the trace non-exhaustive no +matter how many others were scanned, because the reference could be in exactly +that one. + +The second is timing. An append whose write state is indeterminate may still +land, and if it lands it carries a reference to something a cleanup pass has +already decided nothing points at. See +[Session Crash Boundaries](./session-crash-boundaries.md) for how that +indeterminacy arises. So `ReleaseGate` carries the indeterminacy window +alongside the minimum age, and the minimum age has to exceed it. A resource +inside that window is held no matter how thoroughly it was traced: the trace was +accurate, and the history had not finished happening. + +`GateOutcome` is a single value, its zero holds, and `RELEASABLE` is last, so an +unrecognized variant keeps the resource rather than deleting it. The outcomes +that hold say which condition is holding, and `releasable_after` is unset for +the ones that will not resolve by waiting. + +`OrphanClass` enumerates five kinds rather than one, because the cost of getting +it wrong is not uniform. Releasing an abandoned projection generation costs a +rebuild. Releasing a claim check that was about to be referenced destroys the +only copy of a command's output. Releasing an expired reconciliation lease is +not a deletion at all: the work still needs settling, and reclaiming the lease +is what lets someone else settle it. + +That split runs through the repair actions too. +`REPAIR_ACTION_RELEASE_ORPHANED_CLAIM` destroys content the stream cannot +regenerate. `REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE` destroys something it +can. `REPAIR_ACTION_RECLAIM_EXPIRED_LEASE` destroys nothing. An operator +deciding how carefully to look before running one is deciding on exactly that +difference. + +`CHECK_KIND_ORPHAN` stays out of the default check set. Tracing ownership is +expensive, and a check that is expensive enough to be tempting to approximate is +one that should be asked for explicitly. + +And the gate is re-evaluated at repair time, not trusted from the report. +Everything it asserts can stop being true in the interval, which is the same +reason no other repair trusts a finding it did not re-verify. + +## The example, end to end + +A projection checkpoint claims to have processed an event the materialized view +does not contain. + +1. `DiagnoseSession` with the default checks. `CHECK_KIND_PROJECTION` runs. +2. It emits a `FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT` at severity + `DEGRADED`, with a `ProjectionCheckpointDetail` carrying all three positions: + what the checkpoint claims, what the view reflects, and where the source head + is. One or two of those numbers is not a diagnosis. Three is. +3. `available_repairs` offers `RESET_PROJECTION_CHECKPOINT` and + `REBUILD_PROJECTION`. +4. The operator runs `RepairSession` in dry run. The finding re-verifies, and + the result is `WOULD_APPLY` with `affected` naming the generation. +5. The operator re-runs with `APPLY`. + +Nothing between steps 1 and 4 could have mutated anything, and step 4 could not +have either. + +The artifact half of the example diverges usefully. +`FINDING_KIND_ARTIFACT_DIGEST_MISMATCH` carries an +`ArtifactDigestObservation` distinguishing `MISMATCH`, `ABSENT`, and +`UNREADABLE`, because the digests alone cannot. Only `MISMATCH` is evidence of +corruption. `UNREADABLE` is evidence of nothing yet, and the doctor says so +rather than letting an operator infer loss from a failed read. + +## Layout + +`proto/trogonai/session/sessions/doctor/v1alpha1/`: + +| File | Contents | +| --- | --- | +| `finding.proto` | `Finding`, `FindingKind`, `FindingSeverity`, `SubjectRef`, typed details | +| `repair_action.proto` | `RepairAction`, and the rule that bounds it | +| `diagnose_session.proto` | request/response, check selection, budget, per-check outcome | +| `repair_session.proto` | request/response, modes, per-target results | +| `orphan.proto` | `OrphanClass`, `OrphanDetail`, `OwnershipTrace`, `ReleaseGate` | +| `doctor_error.proto` | `DoctorError`, `DoctorErrorCode` | + +A sibling subtree rather than part of `queries`, and its own error type rather +than `QueryError`. The doctor is an operator surface with its own audience and +release cadence; pinning it to the client contract would make every new operator +diagnostic a client-visible change. That is the reasoning +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 3 applies to +projection value types, one subtree further out. + +`FindingKind` is treated as open. A reader meeting an unrecognized kind must +surface it as an unknown finding rather than drop it, and `kind` sits outside +the detail `oneof` so it stays readable when the detail variant does not. A +dropped finding reads as health. + +An expired supervision lease is reachable as an orphan class because the lease +policy is on the log even though the heartbeat never was; see +[Session Detached Work](./session-detached-work.md). + +## Status + +Shipped: the six protos above, lint-clean, formatted, building, and generating +Rust bindings reachable at `trogonai_proto::session::sessions::doctor_v1alpha1`. + +Not shipped: every check, the ownership tracer the orphan check depends on, the +repair executor, diagnosis storage and expiry, the transport binding, and the numeric JSON-RPC error-code reservation, which is +made by decision rather than invented in a proto file. + +The finding taxonomy is ahead of the system it describes. Several kinds name +subsystems that do not exist yet, including projections, snapshots, and the +recovery checkpoint attestations. They are defined now because the taxonomy is +the part that has to be right before anything reports against it, and because a +check added later against an existing kind is not a contract change. diff --git a/docs/architecture/session-maintenance.md b/docs/architecture/session-maintenance.md new file mode 100644 index 0000000000..94d4c4c04e --- /dev/null +++ b/docs/architecture/session-maintenance.md @@ -0,0 +1,263 @@ +# Session Maintenance + +Two operator workflows rewrite or duplicate a session's durable history: +**migration**, which rewrites a session's stored events under a newer storage +schema and keeps its identity, and **salvage**, which copies what can be read +from a damaged session into a new identity. Both can be interrupted between +doing the work and learning that the work landed. This page documents the +protobuf contract that makes that interruption recoverable. There is no Rust +implementation yet. + +See [Session Doctor](./session-doctor.md) for diagnosis, which reports these +problems but is not allowed to fix them, and +[Session Aggregate](./session-aggregate.md) for `SessionOrdinal` and the +creation-batch preconditions both workflows rely on. + +## The failure this exists for + +A migration writes the replacement stream, commits, and then loses the +acknowledgment. The process crashes, or the network drops, or the pod is +evicted. On restart the workflow knows it started and does not know whether it +finished. + +Both available reflexes are wrong. Running the migration again copies a session +that may already have been copied, and the second copy overwrites the first +while looking like progress. Giving up leaves the session in a state nobody will +revisit, because there is no record saying it needs revisiting. + +The workflow has to be able to **look at durable state and decide**, which means +there must be something recorded on the near side of the crash to compare +against. + +## Intent before work, always + +Both workflows write an intent record before touching anything: + +1. Record the intent. +2. Stage the target. +3. Commit. +4. Validate. + +The intent is the whole mechanism. `MigrationIntent.expected_target` carries the +boundary the target will have if the commit lands, computed before the commit is +attempted. After a crash, `ReconcileMigration` reads whatever is at the target +location and compares it to that. The comparison answers a question a bare retry +cannot: not "did some write land" but "did **my** write land." + +`INDETERMINATE_REASON_INTENT_MISSING` exists so that skipping this step is a +reportable condition rather than a mystery. + +### Which means the transformation must be deterministic + +Predicting a target digest before writing it only works if the transformation is +byte-deterministic: the same source bytes and the same `implementation_version` +produce the same target bytes. That is an admissibility requirement, not an +aspiration, and it is why the encoder is scoped to the version rather than +floating. + +`ContentDigest` commits to the event bytes exactly as the log stores them, never +to a re-serialization. Protobuf encoding is not canonical, so a digest taken +over a decode-then-re-encode round trip would not reproduce, and a workflow +whose central check is "is this the same content" cannot rest on a comparison +that fails against bytes the system itself wrote. The +[page cursor envelope](./session-pagination.md) keeps its payload as raw bytes +for exactly the same reason. + +A transformation that cannot reproduce its own output is not a migration. It is +a salvage, and it must mint a new identity. + +## The four verdicts + +`ReconcileMigration` reads and returns one of four answers. It has no mode, no +force, and no field that could make it write, on the same reasoning +`DiagnoseSession` has none: a reconciler that can also commit is a reconciler +that can blindly commit. + +| Verdict | Evidence | Correct action | +| --- | --- | --- | +| `NOT_COMMITTED` | No target exists | Retry under the same identity | +| `COMMITTED` | Target matches the intent exactly | Record success; do not migrate again | +| `DIVERGED` | Target exists and does not match | Stop. No automated action is safe | +| `UNRESOLVED` | The comparison could not be made | Stop. An operator decides | + +`DIVERGED` is the one that matters. A truncated copy written by a prior attempt +and an intact copy written by something else look identical from here, and they +call for opposite actions. Guessing is how a session gets destroyed by the tool +that was supposed to preserve it. + +The user's lost acknowledgment lands on `COMMITTED`, and the workflow reports +`MIGRATION_RESULT_ALREADY_MIGRATED` rather than `MIGRATED`. A retry that claimed +credit for work it did not do would make a fleet run's completion count a +fiction. + +### Unknown and indeterminate are different states + +`MAINTENANCE_STATE_COMMIT_UNKNOWN` says nobody has looked yet, and looking is a +mechanical step the workflow performs on its own. +`MAINTENANCE_STATE_INDETERMINATE` says the workflow looked and the evidence does +not decide. + +Indeterminate is a conclusion, not the absence of one. Collapsing the two would +make an unattended retry loop indistinguishable from a problem that needs a +human, and the second would sit in a queue behind the first forever. + +## Migration keeps ordinals; salvage keeps nothing + +| | Migration | Salvage | +| --- | --- | --- | +| Identity | Preserved | New, derived | +| Ordinals | Preserved exactly | Not preserved | +| Source | Must be intact | Is damaged | +| Source afterwards | Replaced | Untouched | +| Loss | Inadmissible | Expected and enumerated | + +Ordinal preservation is a hard rule, and the reason is that `SessionOrdinal` is +referenced from **outside** the stream it belongs to. A child session's fork +context boundary, checkpoint evidence, a consistency token, a page cursor: each +names a position on someone else's stream. Insert or drop one event during a +migration and every one of those references silently comes to mean a different +event. Nothing fails. Nothing logs. The fork simply inherits a slightly +different prefix than it did yesterday. + +So a migration is one transformed payload per source position, or it is not +admissible. `AdmissibilityReason` enumerates the ways a plan fails that rule: +an event type removed from the target schema, a value the target cannot +represent, source bytes that will not decode. Every one of them is a reason to +reach for salvage instead. **A migration is total or it is not a migration.** + +## Salvage mints a session, and says so + +Salvage has the same lost-acknowledgment problem and solves it more cheaply, +because the write it performs is a creation batch. + +`SalvageIntent.target_session_id` is derived from the salvage identity before +any write is attempted. A retry derives the same id, and the +`[SessionStarted, SessionRecovered]` batch appends under a `NoStream` +precondition, so the duplicate attempt is rejected by the store rather than +resolved by a later comparison. Reconciliation is not needed because the write +itself cannot happen twice. + +A randomly minted id would break this completely: a retry could not find its own +prior work, and every interrupted salvage would leave an orphan session nobody +could attribute. + +### Why `SessionRecovered` is an event + +It would have been simpler to keep salvage provenance in the operator-side +record. It is an event because a projection is rebuilt from the stream, and +provenance that lived only in a journal would vanish on the next rebuild. The +salvaged session would then read as an ordinary session that happens to have a +short history, which is exactly the substitution FX-13 forbids. + +For the same reason the event carries `omitted_count` and not just a pointer to +the record: a fold of this stream alone must be able to conclude the session is +incomplete, without an operator-side lookup that may not be available to it. + +`SessionRecovered` is not `SessionForked`. A fork inherits a prefix it assumes +is valid and references it in place, which requires the source to stay readable +forever. A recovery copies, because the source's readability is the thing that +failed. The copied events are the new session's own events at its own ordinals; +`source_boundary` is provenance, not an index into this stream. + +### What was lost is enumerated, not counted + +`OmittedItem` names each thing the salvage could not carry, with a kind and a +reason. An operator told that three things were lost cannot tell whether they +were three tool results or three user messages, and that difference decides +whether the salvaged session is worth keeping. + +Two omission reasons are worth calling out: + +- `DIGEST_MISMATCH` content is never carried. A salvage that copied content + failing its own integrity check would launder corruption into a session that + looks healthy. +- `ERASED` content was not lost. It was destroyed under a privacy obligation, + and a salvage must not resurrect it. It is recorded so the gap in the salvaged + history is explained rather than read as further damage. + +There is no `recovered_with_unverified_artifacts` result, which is a deliberate +departure from the shape Fx uses. History completeness and artifact +verification are independent axes, and one flat enum forces the server to choose +which fact to report. The omissions carry both, and a second signal that could +disagree with them would only invite a caller to pick. + +## The read side has to show it + +A salvaged session that renders identically to an intact one defeats the whole +workflow. `RecoveryProvenanceView` is therefore on `SessionSummary`, the list +row, and not only on the detail view: a picker is where the substitution +actually happens, because by the time a user opens a session they have already +decided it is theirs. + +The view carries the source id, a completeness value, and a count. It does not +carry the enumerated omissions. A client needs to know the session is +incomplete; rendering a damage report is an operator's job. + +## Modes default to writing nothing + +`MigrationMode` and `SalvageMode` both treat the unset zero value as +`PLAN_ONLY`, matching `REPAIR_MODE_UNSPECIFIED` on the doctor. A caller that +forgets the field gets a plan, and `WOULD_MIGRATE` or `WOULD_SALVAGE` says +plainly that nothing was written. `SALVAGE_RESULT_WOULD_SALVAGE` still carries +the planned omissions, so an operator can see what a salvage would cost before +authorizing it. + +An operation that ran and could not be classified is **not** a +`MaintenanceError`. It is a successful call reporting an indeterminate state, +because it has a durable record and a defined next step, and turning it into an +error would discard both. + +## Layout + +`proto/trogonai/session/sessions/maintenance/v1alpha1/`: + +| File | Contents | +| --- | --- | +| `stream_boundary.proto` | `StreamBoundary`, `ContentDigest`, `OrderProof` | +| `outcome.proto` | `MaintenanceState`, `IndeterminateDetail`, `IndeterminateReason` | +| `migration.proto` | identity, intent, record, result, admissibility | +| `migrate_session.proto` | request/response pair | +| `reconcile_migration.proto` | request/response pair, `ReconciliationVerdict` | +| `salvage.proto` | identity, intent, record, omissions, result, refusal | +| `salvage_session.proto` | request/response pair | +| `maintenance_error.proto` | `MaintenanceError`, `MaintenanceErrorCode` | + +On the write side, `RecoverSession` and `SessionRecovered` join the session +command and event catalogs, and `RecoveryOrigin` joins the aggregate state. +On the read side, `RecoveryProvenanceView` joins `SessionSummary`. + +There are no `service` definitions, matching the rest of this repo. Transport +binding is JSON-RPC over NATS +([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)). + +## Status + +Shipped: the eight protos above, plus `recover_session.proto`, +`session_recovered.proto`, the `SessionRecovered` arm on `SessionEvent`, +`RecoveryOrigin` on `State`, and `RecoveryProvenanceView` on the query contract. +Lint-clean, formatted, building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::maintenance_v1alpha1`. The event validator +covers `SessionRecovered`, including the cross-field rule that a complete +recovery cannot report omissions and a partial one cannot report none. + +Not shipped: the transformations themselves, intent storage, the reconciler, the +salvage reader, and the target-id derivation function. + +The dependency that was open when these protos landed is now settled. +[ADR#0059](../adr/0059-session-stream-incarnation-fencing.md) defines a stream +incarnation as a subject token isolating one rebuild of the physical stream from +the next, so `StreamBoundary.incarnation` is required rather than optional: an +unset incarnation proves nothing, and a comparison that can never fail is not a +comparison. `INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED` now names a +condition the runtime can actually observe, because a boundary read under one +incarnation and a boundary read under another are read through different +subjects. + +That decision also relocates the migration this contract describes. A schema +migration is a rebuild of the physical stream into the next incarnation, which is +what lets it replace a session's stored bytes without any event leaving the log: +the retiring incarnation is sealed and kept, not edited. `MigrateSession` is one +session's participation in that rebuild, which is why ordinal preservation is an +admissibility rule rather than a nicety. Ordinals are the only positions that +survive an incarnation change. diff --git a/docs/architecture/session-pagination.md b/docs/architecture/session-pagination.md new file mode 100644 index 0000000000..bdbce2b85b --- /dev/null +++ b/docs/architecture/session-pagination.md @@ -0,0 +1,251 @@ +# Session Pagination + +`list_sessions` and `get_session_history` are paged, and both page over data +that is being written to while the caller reads it. This page documents the +cursor contract that keeps a multi-page scan from skipping or repeating rows. +It covers the protobuf definitions that exist today. There is no Rust +implementation yet. + +See [Session Query Contract](./session-queries.md) for the queries themselves +and [Session Aggregate](./session-aggregate.md) for `SessionOrdinal`, rewind, +and compaction. + +## The two failures worth designing against + +Paging a growing collection has exactly two ways to go wrong, and they are not +symmetric. + +**Repeating a row** is visible. A transcript shows the same turn twice and +someone files a bug. + +**Skipping a row** is invisible. The page after it looks perfectly well formed, +and nothing in the response says an item is missing. A caller cannot detect it, +which is why the contract has to prevent it rather than report it. + +Two rules do the work: + +1. A cursor names the **identity** of the last row delivered, never a count of + rows delivered. +2. A scan is **pinned** to a boundary chosen when it opened, and never looks + past it. + +Rule 1 is why appends cannot shift a boundary out from under a scan. Rule 2 is +why a scan describes one coherent state of the world rather than a smear across +several. + +## Why not an offset + +The natural anchor is "I have seen 50 items, give me the next 50." It is also +the one thing that cannot work here. + +An offset is an index into a materialized list, so it is only as stable as that +list. In this system the list is a rebuilt read model over an event stream. +Index 50 in one rebuild is not necessarily index 50 in the next, because +rebuilding is allowed to change denormalization, filtering, and grouping. That +is the entire point of a projection being cheap to rebuild. + +`SessionOrdinal` has the opposite property. It is assigned by the fold, it is +1-indexed on the session's own stream, and replaying the same events produces +the same ordinal every time. It survives a rebuild because it is derived from +the stream rather than from the read model. + +So history cursors carry an ordinal, and the count of items is deliberately +absent from `HistoryScanCursor`. + +## History + +The scenario the contract exists for: a user scrolls back through older history +while the agent is still appending new turns. + +A reverse scan opens with the session at ordinal 400 and a page size of 50. + +1. The server pins `anchor_ordinal = 400` and returns ordinals 400 down to 351. + The cursor records `last_delivered_ordinal = 351`. +2. Twelve turns are appended. The session head is now 412. +3. The client asks for the next page with that cursor. The server resumes + strictly below 351 and returns 350 down to 301. + +The twelve new turns sit above the anchor, so they were never candidates. No +row moved, so no row was skipped or repeated. The scan finishes describing +history as it stood at ordinal 400, which is a state that actually existed. + +`GetSessionHistoryResponse.effective_through` carries that anchor and is equal +on every page of one scan. It is the only honest reading of a paged history: a +scan is a snapshot, not a live view. + +That has a consequence worth stating plainly. **An in-progress scan is not how +a caller learns about new turns.** Paging further will never surface them. +Live updates come from the session's event stream, and re-anchoring means +starting a new scan. + +Direction is fixed when the scan opens. A continuation that arrives with the +other direction is refused rather than reversed, because reversing mid-scan +produces a page sequence with a gap in the middle that neither the client nor +the server can see. + +## Sessions + +The list side has a harder problem, and it is worth being explicit about why. + +History is append-only, so a row's position never changes. A session list is +ordered by recency, and recency is mutable. Consider a list ordered newest +activity first, paged without pinning: + +1. Page 1 returns the 50 most recently active sessions. The cursor sits at + position 50. +2. A session ranked 300th receives a message and jumps to position 1. +3. Page 2 returns positions 51 to 100 of the new ordering. + +Every session between the old and new position of that row shifts down by one. +The row now at position 51 was at position 50 and was already delivered, so it +repeats, and one row at the far end falls off the region entirely. Move a few +rows and the scan quietly drops sessions the caller will never see. + +Ordering by something immutable, such as creation order, removes the problem and +also removes the ordering people actually want from a session picker. So the +contract keeps recency ordering and pins the scan instead: +`SessionOrderingKey.ordering_value` is the row's ordering value **as of the +scan's pinned watermark**, not as of now. + +This puts a real obligation on the list projection: it must be able to +enumerate its ordering as that ordering stood at a past watermark, not only as +it stands now. `CursorValidity.pinned_watermark` is where the scan records +which point it needs, and cursor expiry is what bounds how long the projection +has to keep that ability. This contract cannot assert the property by itself, +and a projection that ignores it will silently reintroduce the skip above. + +`ordering_value` alone is not a boundary. Two sessions can share one, and a +boundary that cannot tell them apart has to either re-emit both or drop both. +`session_id` is the tie-breaker, and the full ordering is `ordering_value` +descending then `session_id` ascending. + +The selector is part of the cursor. A continuation that changes scope, +workspace, or the archived filter is refused, because a scan whose selection +changed halfway produces a page sequence that matches neither selection and the +caller has no way to notice. + +## What a cursor is + +A `page_token` is a serialized `CursorEnvelope`. These types are published so +the format is reviewable and versioned, not so clients can read it. A caller +treats a token as opaque bytes and never constructs, parses, or edits one. + +| Field | Purpose | +| --- | --- | +| `CursorEnvelope.format_version` | Envelope format, independent of the query `ContractVersion` | +| `CursorEnvelope.payload` | Serialized `PageCursor` | +| `CursorEnvelope.mac` | Authenticates the exact bytes the server emitted | +| `PageCursor.expires_at` | When the pinned scan stops being honored | +| `HistoryScanCursor.anchor_ordinal` | The pinned effective-history head | +| `HistoryScanCursor.last_delivered_ordinal` | Identity boundary for the next page | +| `SessionListScanCursor.selector` | The request shape the scan was opened with | +| `SessionListScanCursor.last_delivered` | Ordering value plus id tie-breaker | +| `CursorValidity` | Everything the cursor binds to besides its position | + +The envelope keeps `payload` as `bytes` rather than an inline message because +protobuf serialization is not canonical. A server that decoded a cursor and +re-encoded it to verify the MAC could produce a different byte string than the +one it signed, and the check would fail on a token it issued itself. + +### A cursor is a request parameter + +A cursor names a scan position and travels through a client. Without +authentication it is an input the caller controls, and a caller that can edit +one can move the anchor, widen the selector, or point a history scan at another +session's stream. The MAC is what makes that infeasible. + +Two rules follow, and both are easy to get wrong: + +- **A cursor is never authorization.** Every continuation is authorized from the + caller's own identity as if it were a fresh request. A token is not a + capability, and one that leaks must not become access. +- **The request is re-checked against the cursor**, not merely trusted. A + history cursor presented to a different `session_id`, or a list cursor with a + changed selector, is `MALFORMED_CURSOR`. + +## When a cursor stops being valid + +`CursorValidity` exists to answer one question: is the sequence this cursor was +cut from still the same sequence? When it is not, the server refuses rather than +serving a page that looks fine. + +| Change | Field | `StaleCursorReason` | +| --- | --- | --- | +| Rewind retracted effective history | `effective_history_revision` | `REWOUND` | +| Compaction replaced a span | `effective_history_revision` | `COMPACTED` | +| Redaction or artifact erasure | `privacy_revision` | `PRIVACY_CHANGED` | +| Projection rebuilt or replaced | `projection_generation` | `PROJECTION_REPLACED` | +| Server no longer renders the minted major | `minted_contract` | `CONTRACT_CHANGED` | +| Pinned scan outlived its window | `expires_at` | `EXPIRED` | + +Three of these deserve a note. + +**Privacy is tracked separately from rewind** even though both change the +effective prefix. It is the binding that must be checked when nothing else +moved: continuing to serve a scan cut before an erasure keeps handing out +content that was ordered destroyed. Collapsing it into the rewind counter makes +that failure depend on an unrelated code path staying correct. + +**Compaction is distinguished from rewind** because nothing was lost. The same +history is still there, summarized. A caller can restart the scan without +treating it as data loss, and a caller that saw only `REWOUND` could not tell. +This costs the projection something: it has to know which change advanced +`effective_history_revision`, not just that one did. + +**Stale is not malformed.** Stale means the token was genuine and the view +moved, so restarting the scan is the fix. Malformed means the token was never +issued for this request, and retrying is pointless. Merging them would make a +client retry forever on a bug in its own code. + +Expiry exists because a pinned scan is a claim on read-model retention. Without +a bound, an abandoned scan pins a watermark indefinitely. + +## End of scan + +Pagination ends when `next_page_token` is **unset**. An empty page is not the +end signal, because a page can legitimately come back empty while more pages +remain. + +This puts the cost where it belongs. The server must know there is nothing +further before it omits the token, which generally means looking one row past +the page it is returning. The alternative, handing out a token that turns out to +yield nothing, makes every caller pay for one extra round trip and makes "is +this list empty" unanswerable without a second call. + +For that reason there is no `has_more` field, which is a deliberate departure +from the shape Fx uses. Two signals for one fact can disagree, and a caller then +has to decide which to believe. + +## Freshness is a separate question + +`CursorValidity.pinned_watermark` and `ListSessionsResponse.pinned_watermark` +are scan anchors, not freshness reports. They say which point the scan is +enumerating. They do not say whether the projection had caught up to the +caller's own writes when it opened, and a caller cannot derive one from the +other. See [Session Projection Freshness](./session-projection-freshness.md). + +The two contracts meet in one place: consistency is honored when a scan opens +and ignored on continuations, since a continuation is served from the pinned +watermark and waiting for anything newer could not change what it returns. A +continuation asking for more than the scan was opened with is +`INVALID_ARGUMENT` rather than a silently ignored field. + +## Status + +Shipped: `page_cursor.proto`, plus additive changes to `query_error.proto` +(`STALE_CURSOR_REASON_EXPIRED`, `STALE_CURSOR_REASON_COMPACTED`), +`list_sessions.proto` (`pinned_watermark`), and `get_session_history.proto`. +Lint-clean, formatted, building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: cursor minting and verification, the MAC key custody decision, the +list projection's as-of-watermark ordering index, and the retention window that +expiry is derived from. The last two are the load-bearing ones: the guarantee on +this page is only as true as the projection that has to honor a pinned +watermark. + +The same four coordinates `CursorValidity` pins are what a client-held +presentation cache binds to, because the events that invalidate a cursor +invalidate a cache. See +[Session Presentation Caches](./session-presentation-cache.md) for why the two +are separate types anyway. diff --git a/docs/architecture/session-presentation-cache.md b/docs/architecture/session-presentation-cache.md new file mode 100644 index 0000000000..2661bc6217 --- /dev/null +++ b/docs/architecture/session-presentation-cache.md @@ -0,0 +1,150 @@ +# Session Presentation Caches + +A client that reopens a session wants to paint the timeline before its first +query returns. It usually can: it painted the same timeline an hour ago and +still has the rendered result. This page documents the contract that says +whether painting it again is safe. It covers the protobuf definitions that exist +today. There is no Rust implementation yet. + +See [Session Projection Freshness](./session-projection-freshness.md) for what a +projection reports about itself, and [Session Pagination](./session-pagination.md) +for cursors, which are invalidated by the same events for the same reasons. + +## The cache is not stale, it is unbound + +The instinct is to treat a client cache as a time problem: keep it for five +minutes, then refetch. That framing is wrong in both directions. A session +nobody has touched in a month has a cache that is perfectly good after five +minutes and after five weeks. A session someone redacted thirty seconds ago has +a cache that was already unsafe before the timer started. + +Age is not the property that matters. What matters is whether the projection +that produced the cached content still exists and still says the same things, so +the cache carries the projection state it was rendered against and the question +becomes a comparison rather than an estimate. + +`PresentationCacheBinding` is that state: the projection generation, the +processed watermark, the effective history revision, and the privacy revision, +plus the contract version and the client's own renderer version. + +## The same four coordinates as a cursor, deliberately not shared + +Those four projection coordinates are exactly what `CursorValidity` pins for a +page cursor. That is not duplication by oversight. The events that invalidate a +cursor and the events that invalidate a cache are the same events, so the +coordinates have to be the same coordinates. + +They stay separate types because they are checked by different parties. A cursor +is minted by the server, opaque to the client, and validated by the server on +the next page. A binding is held by the client, readable by the client, and +checked before anything is painted. Sharing one message would mean a field added +for the server's validator lands in the client's cache format, and a change made +for the client's benefit lands in an opaque token clients are told never to +parse. + +## Older is not the same as a prefix + +The useful case is a cache at a lower watermark than the current projection. +The client paints what it has and reads forward from there, which is the only +arrangement that shows something before the first query returns. + +That is only correct when history between the two watermarks was append-only. It +usually was. It is not after a rewind, a compaction, a redaction, or an artifact +erasure, because all four *retract* content that was there. After any of them a +lower watermark is not a prefix of a higher one, and the cached rows include +rows that no longer exist. + +So `CACHE_USABILITY_APPENDABLE` is gated on the two revisions matching, not on +the watermark being lower. A lower watermark alone does not establish that the +interval only added. + +The redaction case is the one worth stating plainly, because it is not a +staleness annoyance. A cache painted after a redaction puts content someone +deliberately destroyed back on a screen, in front of a person. That is the +failure the redaction was performed to prevent, arriving through the code path +added to make the app feel fast. + +`privacy_revision` is tracked apart from `effective_history_revision` for that +reason: it is the one that must be checked even when nothing else moved. + +## The verdicts + +`CacheUsability` is a single value rather than a set of flags, so a client +cannot read the half it likes. + +| Value | Meaning | +| --- | --- | +| `UNSPECIFIED` | Unknown verdict. Discard. | +| `CURRENT` | Every coordinate matches. Paint as final. | +| `APPENDABLE` | Strict prefix. Paint, then read forward from the cached watermark. | +| `RETRACTED` | Content the cache holds no longer exists. Discard all of it. | +| `REPLACED` | Different projection generation. Not old output, foreign output. | +| `INCOMPATIBLE` | Contract major or renderer version differs. | +| `INDETERMINATE` | The server could not decide. | + +The zero value discards, so a client reading a variant added after it was built +falls back to fetching rather than to painting. + +`RETRACTED` and `REPLACED` are separate because they are different problems. In +the first the projection is fine and history changed underneath it; in the +second the projection is gone and the content came from a computation that no +longer runs. `RETRACTED` also has no partial answer: the client cannot know +which of its rows were the retracted ones, so it discards all of them. + +`INDETERMINATE` exists so a degraded server can say it does not know instead of +resolving to a discard. Resolving to a discard would turn a projection outage +into a refetch storm the same outage cannot serve. + +## Checking is not reading + +`CheckPresentationCache` is not a read. A caller that wanted the content would +call `GetSessionHistory`; this is for the caller that already has content and +needs a verdict more cheaply than fetching it again. There is no field on the +request that could make it return timeline data, so it cannot quietly grow into +the expensive path it was added to avoid. + +The response still carries `current`, the binding a fresh render would use, on +every verdict including a discard. A client about to refetch already knows what +to bind the replacement to, without a second round trip. + +## Rendering state stays in the client + +Nothing here describes the rendering. Terminal width, scroll position, theme, +and ANSI handling are the client's state and stay there. The event log records +what happened, not what a viewer looked like while watching it, and a projection +that stored presentation state would have to be rebuilt every time a renderer +changed. + +`renderer_version` is the one concession, and the server never interprets it and +never compares it. It is carried so a client shipping a new renderer can discard +its own caches without the server knowing anything about renderers. + +## Layout + +`proto/trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto`: + +| Message | Contents | +| --- | --- | +| `PresentationCacheBinding` | the projection state a cache was rendered against | +| `CheckPresentationCacheRequest` | session, contract, held binding | +| `CheckPresentationCacheResponse` | verdict, current binding, freshness | +| `CacheUsability` | what the client may do with what it holds | + +No `service` definitions, matching the rest of this repo: transport binding is +JSON-RPC over NATS ([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)). + +A session's derived title and preview invalidate against the same two revisions +this binding does, for the same reason; see +[Session Title and Preview](./session-title-and-preview.md). + +## Status + +Shipped: `presentation_cache.proto`, lint-clean, formatted, building, and +generating Rust bindings reachable at +`trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: the projection that would track `effective_history_revision` and +`privacy_revision`, the handler, and the client cache itself. Until the two +revision counters are actually maintained, the only honest verdict a server +could return is `INDETERMINATE`. diff --git a/docs/architecture/session-projection-freshness.md b/docs/architecture/session-projection-freshness.md new file mode 100644 index 0000000000..23cef37816 --- /dev/null +++ b/docs/architecture/session-projection-freshness.md @@ -0,0 +1,222 @@ +# Session Projection Freshness + +Session queries read projections, and a projection is behind the stream it is +built from. This page documents the contract that makes that lag visible, and +the mechanism a caller uses to read its own writes. It covers the protobuf +definitions that exist today. There is no Rust implementation yet. + +See [Session Query Contract](./session-queries.md) for the queries and +[Session Pagination](./session-pagination.md) for cursors, which interact with +freshness in a way worth knowing about. + +## The problem + +A user redacts a message and the UI immediately re-reads the session. The +projection has not applied the redaction yet, so the response contains the +content that was just ordered destroyed. The response is well formed. Nothing in +it is wrong as far as the projection knows. The user is looking at a screen +that contradicts what the system just told them happened. + +Redaction is the sharp version, but the shape is general: a read that is correct +as of the projection can be wrong as of what the caller already knows. The +caller is the only party with enough information to notice, and only if the +server tells it where the projection stands. + +Two fields carry the whole contract: + +- Every **request** may declare `ReadConsistency`, the freshness it requires. +- Every **response** carries `ProjectionFreshness`, how current the read model + was when it answered. + +This is the same shape the versioning contract uses, and for the same reason: +the caller states its requirement before the server renders, so a mismatch +becomes a typed refusal rather than a plausible wrong answer. + +## Reading your own write + +`ReadConsistency` has two modes. + +`EVENTUAL` is the default and the common case. Serve whatever the projection +has. Freshness still comes back, so a caller that cares can look. + +`AT_LEAST` carries a `ConsistencyToken` naming a write the read must reflect, +and a `max_wait` budget. The server answers once the projection has applied that +position, or fails. + +Walk the redaction: + +1. The caller applies a redaction. The write lands at `SessionOrdinal` 87. +2. The caller re-reads with `mode = AT_LEAST`, `token = {session, 87}`, + `max_wait = 500ms`. +3. The projection is at 85. The read waits. +4. At 87 the read answers, with `condition = CURRENT`, + `processed_watermark = 87`, and `consistency.result = SATISFIED_AFTER_WAIT`. + +If the projection is still at 85 when the budget runs out, the read fails with +`PROJECTION_UNAVAILABLE` and `REASON_LAGGING`, carrying the freshness it +reached. That last part is what makes the failure actionable: a caller that can +see it got to 85 and needed 87 can retry with a larger budget, while a caller +handed a bare error can only guess. + +The wait budget belongs to the caller because only the caller knows whether it +is serving an interactive request. Unset means do not wait at all: answer if the +projection is already there, fail otherwise. + +### Why the token is not opaque + +Page cursors are authenticated bytes. Consistency tokens are a plain typed +message, and the asymmetry is deliberate. + +A cursor names a scan position, so it is an instruction the server follows, and +a forged one is a way to read what the caller should not. A token can only make +a read wait or fail. The worst a forged one achieves is the caller's own bounded +wait followed by a `LAGGING` error, and it discloses nothing. A MAC would buy +nothing here and would cost every caller the ability to debug its own reads. + +The token uses a `SessionOrdinal` rather than a stream sequence, for the same +reason a cursor does: it is fold-derived and reproduces identically on replay, +so it survives a projection rebuild. A list read uses one too. A list projection +that consumes many streams still knows how far it has applied each one, and "the +list reflects my change to session X" is the only freshness question a caller +actually has about a list. + +## What a response reports + +| Field | Meaning | +| --- | --- | +| `condition` | `CURRENT`, `LAGGING`, or `INDETERMINATE` | +| `projection_generation` | Which projection instance answered | +| `processed_watermark` | How far it has applied | +| `processed_at` | Event time of the last applied event | +| `source_high_watermark` | The source head, as most recently observed | +| `source_observed_at` | When that observation was made | +| `consistency` | What the server did about the caller's requirement | + +Three things here are easy to get wrong. + +**`INDETERMINATE` is not a degraded `CURRENT`.** Observing the source head costs +a round trip the read path does not always pay. Rather than let a server report +a fabricated head, the contract lets it decline, and the condition then says so. +A caller that needs to know it is reading a write it just made states that with +`ReadConsistency`. It does not infer currency from a condition that means the +server did not check. + +**`processed_at` is not a consistency boundary.** Event time is not monotonic +across writers, so comparing timestamps to decide whether a write is included +will eventually be wrong. It is there for a human-facing "as of". Compare +watermarks. + +**An unset `source_high_watermark` is not a head of zero.** This is the same +rule the query contract already applies to its elision counters: reporting zero +and not reporting are different statements, and a field that cannot express the +difference forces the server to lie. + +### Why the condition enum is small + +FX-05 lists five projection states. This enum has three, because the other two +are failure-path conditions and already have a home. + +A projection that is rebuilding, invalid, or missing either serves nothing, in +which case the caller gets `PROJECTION_UNAVAILABLE` with the matching reason, or +serves a readable prior generation, in which case it is simply `LAGGING`. +Expressing those states in both places would create two ways to say one thing +and invite them to disagree. + +That gives a clean rule for rebuilds: a rebuild that keeps the prior generation +readable answers with `LAGGING`, and a destructive one fails with +`REBUILDING`. Either way `projection_generation` changes when the new +generation takes over, which is what invalidates page cursors minted against the +old one. + +## When the projection cannot answer + +A projection that is lagging still answers; the caller reads `LAGGING` and +decides. A projection that is corrupt, missing, or mid-rebuild cannot answer at +all, and the two options left are both worse than a normal read. + +The first is to fail: `QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE` with a reason. +The second is to fold the session's own stream and answer from the log, which is +the authoritative source the projection is a cache of. `AnswerSource` on +`ProjectionFreshness` is what makes the second option expressible. Without it a +replay answer and a projection answer are the same shape, and a caller cannot +tell that it just paid for a fold or that a few of its usual assumptions no +longer hold. + +Falling back is admissible only for a read scoped to one session, because only +then is there a bounded stream to fold. `ListSessions` has no such bound: a +fallback there means replaying every stream a caller can see, which is not a +degraded read, it is an outage with extra steps. So a list query under a +projection failure has exactly two honest outcomes, an answer or a refusal, and +the contract says so rather than leaving it to whoever implements the handler +during the incident. + +A replay answer reports `CURRENT`, since the fold ran to the head it read at, +and its `projection_generation` is empty. There is no projection instance to +name, and minting a synthetic one would be worse than leaving it blank: a page +cursor pins the generation it was created under, so a synthetic id is a value a +cursor can bind to and nothing can later honor. The consequence is stated on the +enum. A replay answer must not mint a page cursor, so a caller that needs to +paginate through a projection outage waits for the projection rather than +scanning against a fallback that cannot continue. + +## Rebuilding is a state, not a silence + +`PROJECTION_UNAVAILABLE_REASON_REBUILDING` tells a caller to come back shortly. +On its own that is a claim with no number attached, and it leaves a client +choosing between polling a rebuild that will take four hours and giving up on +one that will take four seconds. + +`RebuildProgress` attaches the number: when the rebuild started, the position it +has applied through, and the position it is working toward. The target is +optional, and unset is the honest answer for a rebuild over a stream that is +still being written to. Reporting the current head as the target instead would +produce a percentage that goes backwards, which is worse than no percentage. + +Absent progress means the rebuilder could not say. That is deliberately not the +same as a rebuild that has made no progress, and the field is absent rather than +zeroed so the two cannot be confused. + +## Interaction with pagination + +A paged scan is pinned to a watermark chosen when it opened. So consistency is +honored when the scan opens and **ignored on continuations**: a continuation is +served from the pinned watermark, and waiting for anything newer could not +change what it returns. + +That leaves a hole worth closing explicitly. A caller could pass a stricter +requirement on page 2 and believe the page reflects a write it cannot possibly +reflect. A continuation whose requirement exceeds the one the scan was opened +with is therefore `INVALID_ARGUMENT`, not a silently ignored field. + +The two contracts cover different halves of the same question, and the redaction +example needs both. `effective_through` says which ordinal the scan covers. +`ProjectionFreshness` says whether the projection had applied the event at that +ordinal when the scan opened. Neither answers for the other. Separately, a +redaction landing mid-scan bumps `privacy_revision` and the next continuation +fails with `STALE_CURSOR` and `PRIVACY_CHANGED`, so an in-flight scan cannot +keep serving pre-redaction content either. + +## Not in Session events + +None of this is derived from Session events and none of it belongs in one. A +watermark describes the read path's progress, which is not a fact about the +session. Recording it as an event would make the event log depend on the +projections built from it. + +`ProjectionFreshness` is query metadata, and the same values are the natural +source for read-path observability. + +## Status + +Shipped: `projection_freshness.proto` and `read_consistency.proto`, plus +additive fields on all three request/response pairs, `AnswerSource`, and +`RebuildProgress` on `ProjectionUnavailableDetail`. Lint-clean, formatted, +building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: the projections themselves, watermark tracking, the wait mechanism, +the replay fallback path, the rebuilder that would report progress, and the +command-response shape that hands a caller a `ConsistencyToken` after a +write. That last one is the gap that matters most for the redaction case: the +contract can express the requirement, but nothing yet tells a caller which +ordinal its write landed at. diff --git a/docs/architecture/session-provider-faults.md b/docs/architecture/session-provider-faults.md new file mode 100644 index 0000000000..5432d94a80 --- /dev/null +++ b/docs/architecture/session-provider-faults.md @@ -0,0 +1,127 @@ +# Session Provider Faults + +A provider emits a tool call with truncated JSON arguments, or with an empty id, +or with an id it already used. The call cannot run. This page documents where +that fact goes, and why it could not go anywhere that already existed. It +documents the protobuf contract that exists today. There is no Rust +implementation yet. + +See [Session Aggregate](./session-aggregate.md) for the tool call lifecycle this +sits outside of. + +## The malformed intent has nowhere to live + +This is not a design preference. The canonical transcript shape for a tool call +is `ToolUseBlock`, and its `input_json` is required and must be valid JSON. An +intent whose arguments are truncated JSON has nothing to put in that field. The +shape structurally cannot hold the thing that went wrong. + +The raw provider payload is retained, in `ProviderBlock`. But `ProviderBlock` is +documented write-verbatim, read-never: no projection may interpret it. Mining it +to answer "why did this turn do less than it looked like it did" would make a +read model depend on a shape the domain explicitly promised never to read, and +the promise is what lets providers change their payloads without breaking +anything downstream. + +So the options were a typed event or nothing. Nothing means the most common +provider fault in production leaves a session that silently did less than it +appeared to, with the evidence sitting in a field no reader is allowed to open. + +`ProviderToolIntentRejected` is the typed event. + +## It is not a denial + +`ToolCallDenied` is the closest existing event and it is the wrong one. + +A denial is a well-formed request that a human, a policy, or a hook refused. The +request exists, it is on the log as `ToolCallRequested`, and the denial is a +decision about it. Here there is no admissible request at all. Nothing is +written to `ToolCallRequested`, no execution id is minted, and no operation is +reserved. + +Refusing to synthesize a request is the point. Manufacturing a `ToolCallRequested` +out of unparseable input would put a call on the permanent log that the provider +never validly asked for, and every later reader would see the session as having +attempted something it did not. + +## It is per intent, not per message + +A model can emit ten tool calls in one message. If nine are sound and the tenth +is malformed, the nine must still run. + +That is why this is not a new `AssistantMessageFailureReason`. Marking the +message failed would discard nine good calls in order to describe one bad one. +The nine proceed to `ToolCallRequested` normally, and only the tenth lands here, +carrying `message_id` so the association is still recoverable. + +## The claimed id is a claim, never an identity + +`claimed_tool_call_id` holds whatever the provider said, verbatim, including +empty. It must never be joined against `tool_call_id` anywhere. + +The whole point of the duplicate case is that the value collides with a real +call. Admitting it into a join would attribute one call's result to another and +make every downstream correlation quietly wrong. The field name says "claimed" +because that is all it is: a record of what was asserted, kept for diagnosis, not +for lookup. + +The same reasoning explains why `rejection_id` is minted by the runtime rather +than taken from the provider. The entire fault class is that the provider's +identifier is missing, empty, or duplicated. It cannot be the key. + +## The raw payload goes out of line + +`raw_intent` is a claim-check, not inline bytes. + +Malformed input has no length bound, and this is the one payload in the system +whose size is set by whatever produced the fault. A megabyte of truncated JSON +inlined into a log that is never truncated +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7) makes one +bad generation permanent for every reader of the stream, forever. It goes to an +artifact, like every other unbounded payload, and it is erasable like one. + +Unset means the raw emission could not be captured, which is worth +distinguishing from a capture of nothing. + +## Why the reasons are typed + +`ProviderToolIntentRejectionReason` is an enum rather than a string because the +operational responses genuinely differ: + +| Reason | What it means operationally | +| --- | --- | +| `MALFORMED_ARGUMENTS` | a prompt or model problem, often a token limit | +| `SCHEMA_VIOLATION` | the tool's declared schema and the model's understanding disagree | +| `MISSING_CALL_ID` | a provider protocol violation | +| `DUPLICATE_CALL_ID` | a provider bug that corrupts joins if ever admitted | +| `UNKNOWN_TOOL` | catalog drift between what was offered and what is registered | +| `UNRESOLVABLE_PARENT` | the call tree cannot be reconstructed | +| `OVERSIZED` | refused before parsing, as an input bound | + +Collapsed into one free-text reason, all seven become a single unactionable +alert. + +## Layout + +`proto/trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto` +and its paired command +`proto/trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto`. + +| Type | What it settles | +| --- | --- | +| `ProviderToolIntentRejected` | the intent existed, was refused, and never became a call | +| `ProviderToolIntentRejectionReason` | which fault, in terms an operator can act on | +| `RejectProviderToolIntent` | the command, with the payload already stored | + +It is arm 43 of `SessionEvent`, and a commuting happened-fact +(`WRITE_PRECONDITION = Any`, +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 2): the provider +already did it, and no lifecycle state can make it untrue. + +## Status + +Shipped: both protos, lint-clean, formatted, building, wired into the event +catalog and its codec and validator, with tests. + +Not shipped: the provider adapter that detects these faults and issues the +command. Nothing produces the event yet. diff --git a/docs/architecture/session-queries.md b/docs/architecture/session-queries.md new file mode 100644 index 0000000000..08e7661b61 --- /dev/null +++ b/docs/architecture/session-queries.md @@ -0,0 +1,244 @@ +# Session Query Contract + +The Session query contract is the public read surface of the Session Store: +`get_session`, `list_sessions`, and `get_session_history`, each with an explicit +version and a typed error taxonomy. This page documents the protobuf contract +that exists today. There is no Rust implementation yet. + +See [Session Aggregate](./session-aggregate.md) for the write side. The two are +deliberately separate contracts, and the reason is the whole point of this page. + +## Why a query proto exists at all + +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 8 says queries +have "no query protos, since the projection value is the read contract." This +contract departs from that, and the departure should be reviewed rather than +assumed. + +The problem with a projection value as the public contract is that it makes one +type serve two masters. A projection exists to be rebuilt: it changes whenever +the read model needs different denormalization, and rebuilding it is cheap +precisely because nothing outside the service depends on its shape. A public +read contract exists to hold still: clients compile against it and ship on their +own schedule. Making them the same type means every read-model change is a +client-visible change, and the read model stops being cheap to rebuild. + +So the query types here are defined in their own package and redefine their +value types locally rather than importing write-side or projection types. That +is the same rule [ADR#0035](../adr/0035-session-store-decider-aggregate.md) +facet 3 already applies to the `state`, `projections`, and `checkpoints` +subtrees, extended one step further out. + +That departure is now on the record rather than on this page. +[ADR#0060](../adr/0060-session-query-contract-separate-from-projection.md) +withdraws facet 8's clause and states the reversal, and facet 8 carries the +reciprocal amendment. Everything else in facet 8 stands: no read model is +authoritative, projections are folded and checkpointed from the log, and these +handlers are still `verb + noun` Rust functions reading a KV projection. + +## Layout + +`proto/trogonai/session/sessions/queries/v1alpha1/`: + +| File | Contents | +| --- | --- | +| `contract_version.proto` | `ContractVersion`, `ContractNegotiation` | +| `query_error.proto` | `QueryError`, `QueryErrorCode`, typed details | +| `session_view.proto` | `SessionView`, `SessionSummary`, lifecycle enums | +| `history_item.proto` | `HistoryItem` and its variants | +| `get_session.proto` | request/response pair | +| `list_sessions.proto` | request/response pair | +| `get_session_history.proto` | request/response pair | +| `page_cursor.proto` | cursor envelope and scan positions | +| `read_consistency.proto` | the freshness a caller requires | +| `projection_freshness.proto` | the freshness a response reports | +| `presentation_cache.proto` | binding and verdict for a client-held cache | +| `latest_session.proto` | the single newest eligible session in a workspace | + +There are no `service` definitions, matching the rest of this repo: transport +binding is JSON-RPC over NATS ([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)), and these are the +body types. Query naming follows verb + noun per +[ADR#0014](../adr/0014-command-and-query-naming.md). + +## Versioning + +Two fields carry the whole scheme: + +- Every **request** declares `accepted_contract`, the highest version the caller + understands. +- Every **response** carries `contract`, holding both the version it was + `rendered` at and the server's `server_max`. + +The compatibility rule is ordinary: same `major` is compatible, different +`major` is not. `minor` increments only for additive changes (a new optional +field, a new enum value, a new union variant); `major` increments for anything a +caller built against the prior version could misread. + +What makes it work is that the caller declares its version *before* the server +renders anything. + +### Clamping, not just detecting + +A version field that only appears on the response lets a client detect an +incompatibility after it has already failed to parse something. This contract +goes further: **the server renders at no higher than the caller's declared +minor.** A caller never receives a variant it cannot decode. + +Walk the example. A client is built against `1.2`. The server ships `1.4`, which +added a new history item variant. + +1. Client sends `accepted_contract = {major: 1, minor: 2}`. +2. Server sees a matching major, so the request is serviceable. +3. Server renders history. An item that needs the `1.4` variant cannot be + expressed at `1.2`, so it is emitted as `HISTORY_ITEM_KIND_ELIDED` with + `reason = ELISION_REASON_CONTRACT_CLAMPED`. +4. Response carries `rendered = 1.2`, `server_max = 1.4`, and + `contract_clamped_count = 1`. + +The client now knows three separate things it could not otherwise distinguish: +the answer is readable, one item was withheld, and upgrading would reveal it. If +instead the client had sent `major: 2`, the server would refuse with +`QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION` carrying the supported major +range, rather than answer in a shape the client cannot read. + +### Why the discriminated union needs help + +A `oneof` cannot express "a variant you do not know." A client decoding an arm +added after its version sees an unset `oneof`, indistinguishable from a variant +that was never set. Silently rendering nothing for a real event is a correctness +failure. + +`HistoryItem` closes this two ways: + +- `kind` is a plain enum **outside** the `oneof`. Proto enums are open, so an + unrecognized kind survives decoding as its raw number. A client can always + tell something is there. +- Elision is **affirmative**. `HISTORY_ITEM_KIND_ELIDED` with a reason is a + positive statement that an item was withheld, not an absence the client has to + infer. + +`item_id` stays stable across an elision, so a client that upgrades sees the same +item resolve to a real variant rather than a new entry appearing. + +One codegen constraint worth knowing: this repo generates with +`unknown_fields=false`, so unknown fields are **dropped** on decode, not +preserved. A relay cannot round-trip a newer response through an older +decoder without loss. The clamping rule is what keeps that from mattering. + +## Errors + +`QueryError` is not a variant inside a success response. A query either answers +or fails, and merging the two invites a client to read a zero-valued success +shape as an empty result. + +`code` is the only field to branch on. `message` is for humans, non-contractual, +and may change without a version bump. + +| Code | Meaning | +| --- | --- | +| `SESSION_NOT_FOUND` | No such stream | +| `UNSUPPORTED_CONTRACT_VERSION` | Major mismatch; carries the supported range | +| `INVALID_ARGUMENT` | Malformed input; carries a field path | +| `STALE_CURSOR` | Cursor was genuine, the view moved; carries a reason | +| `MALFORMED_CURSOR` | Cursor was not issued for this request, or fails its MAC | +| `PROJECTION_UNAVAILABLE` | Read cannot be served now; carries a reason | +| `PERMISSION_DENIED` | Not authorized | +| `RESOURCE_EXHAUSTED` | Valid but too expensive as asked | +| `INTERNAL` | Unexpected failure, no detail by design | + +Three distinctions here exist because collapsing them loses information a caller +needs to act: + +- **Stale vs malformed cursor.** Stale means restart the scan; malformed means + fix the client. Retrying a malformed cursor is pointless. +- **Not-found vs permission-denied.** Where disclosing the difference would let + a caller prove a session exists, the server returns `PERMISSION_DENIED` for + both. Otherwise the error code becomes an existence oracle. +- **Rebuilding vs invalid projection.** `ProjectionUnavailableDetail` separates + "come back shortly" from "this is broken." A caller cannot guess which from the + code alone, and the retry behavior differs. + +The numeric JSON-RPC code assignment is **not** made here. That space is +reserved by decision, as [ADR#0017](../adr/0017-aauth-agent-authentication.md) +did for `-32118`, and inventing numbers in a proto file would bypass it. + +## Completeness is reported, never implied + +A response that parses is not evidence that it is complete. Three counters say +otherwise, and a client that ignores them will present partial data as whole: + +- `ListSessionsResponse.skipped_count`: rows the server could not decode or + render. Non-zero means the list is not exhaustive. +- `GetSessionHistoryResponse.contract_clamped_count`: items withheld because the + caller's version is too old. Upgrading reveals them. +- `GetSessionHistoryResponse.withheld_count`: items withheld by redaction or + authorization. Upgrading does **not** reveal them, so a client should not + prompt for one. + +`SessionSummary.recovery` is the same rule applied to provenance rather than +completeness. A session salvaged from a damaged one is missing content the +original had, and a list row that renders it identically to an intact session +is where a user decides it is the session they were looking for. See +[Session Maintenance](./session-maintenance.md). + +The same principle drives `SessionView.has_unreconciled_work`. A session can +reach a terminal lifecycle while a tool call it started never recorded an +outcome. A reader that treats terminal as complete will show a finished session +that still has work stranded in the ledger, so the fact is surfaced explicitly. + +`SessionView.artifacts` extends it to content the session produced but no longer +holds. Artifact bytes live outside the log and can be erased or lost without the +session changing at all, so retrievability is reported separately from lifecycle +rather than inferred from it. See [Session Artifacts](./session-artifacts.md). + +End-of-scan follows the same rule: pagination ends when `next_page_token` is +**unset**, not when a page comes back empty. A page can legitimately be empty +while more pages remain. + +## Pagination + +`page_token` and `next_page_token` are opaque `bytes` carrying a serialized +`CursorEnvelope`. What a token binds to, how a scan stays stable while the +session is still being written to, and exactly when a cursor goes stale are +documented in [Session Pagination](./session-pagination.md). + +That contract landed after this one and demonstrates the versioning rule +working as intended: it added `page_cursor.proto`, two `StaleCursorReason` +values, and one response field, all additive, so a client built against the +prior minor keeps working unchanged. + +## Freshness + +Every request may declare a `ReadConsistency` and every response carries a +`ProjectionFreshness`, so a caller can tell whether the view it received +reflects a write it just made. See +[Session Projection Freshness](./session-projection-freshness.md). + +Like pagination, that contract landed after this one and arrived entirely as +additive fields: two new protos, new fields on all three request/response pairs, +and one new field on `ProjectionUnavailableDetail`. Nothing a client built +against the prior minor had to change. + +## Beyond the three reads + +Two contracts sit alongside these and are documented on their own pages. A +client that reopens a session can check a cache it already holds instead of +refetching it, which is +[Session Presentation Caches](./session-presentation-cache.md). A resume command +needs the one newest eligible session in a workspace rather than a page it has +to filter, which is [Session Resume Index](./session-resume-index.md). + +How a row's title and excerpt are resolved, and what their absence means, is +[Session Title and Preview](./session-title-and-preview.md). + +## Status + +Shipped: the twelve protos above, lint-clean, formatted, building, and generating +Rust bindings reachable at `trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: query handlers, the projections they read, the transport binding, +and the numeric JSON-RPC error-code reservation. + +`v1alpha1` is honest: this contract cannot be promoted to `v1` before the +projections it reads exist. diff --git a/docs/architecture/session-resume-index.md b/docs/architecture/session-resume-index.md new file mode 100644 index 0000000000..62990b2e5c --- /dev/null +++ b/docs/architecture/session-resume-index.md @@ -0,0 +1,130 @@ +# Session Resume Index + +A resume command needs one session: the newest one in a workspace that it is +actually allowed to attach to. This page documents the query contract for that +answer. It covers the protobuf definitions that exist today. There is no Rust +implementation yet. + +See [Session Query Contract](./session-queries.md) for the list and detail +reads, and [Session Projection Freshness](./session-projection-freshness.md) for +what a response says about how current it is. + +## Filtering after the list is the wrong order + +The available move today is to call `ListSessions` ordered newest first and take +the first row that qualifies. It works until it does not. The list is ordered by +recency and filtered afterwards, so a workspace whose forty most recent sessions +are all running returns a page with no answer in it and no way to tell that a +longer page would have found one. The caller either pages until it finds +something or gives up, and both are decisions it is making blind. + +Selection has to happen in the index. `GetLatestSession` asks the question +directly and gets a single session or nothing. + +This is also where staleness costs the most. A stale list is a list with an old +row in it, which a human reading a picker can see and ignore. A stale +latest-pointer is the one answer the caller acts on, so the entire error lands +on whichever session gets opened. + +## The selector is an enum, not a set of filters + +Booleans let a caller ask for a session that is both currently active and not +currently active, and then the server has to decide what an impossible request +means. `SessionSelector` has three values, each a question someone actually +asks: + +- `MOST_RECENT`: the newest non-archived session, whatever state it is in. +- `RESUMABLE`: the newest one a resume can attach to. +- `ACTIVE`: the newest one currently being driven, for reattaching. + +The zero value is refused rather than defaulted. There is no default that is +safe for both callers: a picker wants the most recent session of any kind, a +resume wants a resumable one, and guessing wrong hands a resume command a +session that is already running somewhere else. + +Terminal is not one of `RESUMABLE`'s exclusions. A closed session is the +ordinary thing to resume; that is what resuming means. What is excluded is a +session already being driven from elsewhere, which resuming would turn into two +writers on one stream. + +## Empty is defined on authored content + +"Exclude empty sessions" needs a definition, and `effective_length` is not it. A +session can carry configuration and lifecycle records and still be one nobody +ever said anything in. A rewind to the start empties a session that was not +empty an hour ago. Redaction can mask an ordinal without removing it. + +So emptiness is defined as no user-authored turn in effective history. Resuming +a session that fails that test puts a person back into a blank window they have +no memory of leaving. + +## Latest by which clock + +`RecencyBasis` picks between last activity and creation, because the two +orderings disagree often. A long session started yesterday and worked on this +morning is the newest by activity and among the oldest by creation. + +Both timestamps behind it are recorded external occurrences, not positions +derived from append order (D10), so a projection that catches up late does not +reorder the answer. + +## An empty answer has to say why + +Absence is a normal outcome and is returned as an unset field rather than an +error, because a first-run workspace is not a failure. + +But "no resumable session" and "eleven sessions, all still running" are the same +absence to a caller that only sees an empty field, and they call for opposite +next moves: create a new session, or attach to a running one. `ExclusionCounts` +is what distinguishes them. It reports `considered` as the denominator, so zero +there means an empty workspace rather than an over-strict selector, and then one +count per rule. + +A session removed by more than one rule is counted once, under the first rule +that removed it, in declaration order. Counting it under every matching rule +would give totals larger than the workspace, and the number a caller wants is +how many sessions there were, not how many judgements were made. + +`unrenderable` is the count that changes the meaning of the whole response. +Non-zero means the answer may be wrong rather than merely empty, because the +session that should have won might be one of the rows the projection could not +render. That is the same rule `ListSessionsResponse.skipped_count` follows, and +it matters more here: a list with a missing row is incomplete, and a +latest-pointer with a missing row is incorrect. + +## The index is disposable + +Everything this query reads is a projection, rebuildable from the stream, so it +carries `ProjectionFreshness` like every other read and a caller can require +consistency when it needs to. Nothing about the index is authoritative, and +nothing about it belongs in an event: which session is newest is a fact derived +from the sessions, not a fact about any one of them. + +## Layout + +`proto/trogonai/session/sessions/queries/v1alpha1/latest_session.proto`: + +| Message | Contents | +| --- | --- | +| `GetLatestSessionRequest` | workspace, selector, recency basis, consistency | +| `GetLatestSessionResponse` | the session or nothing, exclusions, freshness | +| `SessionSelector` | which session counts as the answer | +| `RecencyBasis` | which clock "latest" is measured by | +| `ExclusionCounts` | what each rule removed, and the denominator | + +No `service` definitions, matching the rest of this repo: transport binding is +JSON-RPC over NATS ([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)). Query naming +follows verb + noun per [ADR#0014](../adr/0014-command-and-query-naming.md). + +## Status + +Shipped: `latest_session.proto`, lint-clean, formatted, building, and generating +Rust bindings reachable at +`trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: the index itself, the handler, and the notion of a session being +currently driven, which nothing in the aggregate tracks yet. `SESSION_SELECTOR_ACTIVE` +and the `active` exclusion count are contract ahead of mechanism, defined now +because the semantics are the part that has to be settled before anything +indexes against them. diff --git a/docs/architecture/session-schema-boundaries.md b/docs/architecture/session-schema-boundaries.md new file mode 100644 index 0000000000..b93113f26e --- /dev/null +++ b/docs/architecture/session-schema-boundaries.md @@ -0,0 +1,230 @@ +# Session Schema Boundaries + +This page records what is deliberately not in the session schema, and why. + +There are two kinds of absence here. Three fields were proposed and declined: +a conversation language, an external work identity, and per-tool telemetry. And +fifteen storage shapes that other session stores adopt are absent by design, +recorded here because a shape that is merely missing looks like an oversight. + +A decision not to add something is worth writing down for the same reason an +addition is: otherwise it gets re-proposed every time somebody notices the gap. + +See [Session Aggregate](./session-aggregate.md) for the catalog these were +weighed against and [Event Metadata](./event-metadata.md) for the payload and +header boundary two of them turn on. + +## The test a proposed field has to pass + +An event payload is a canonical domain fact: something replay, a projection, or a +business rule depends on +([Event Metadata](./event-metadata.md)). The question for any proposed field is +therefore narrow, and it is not "is this useful". + +**Does a fold rule or an invariant read it?** + +If nothing in the aggregate conditions on a value, putting it on an event +commits the domain to carrying it forever, in a log that is never truncated +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7), for the +benefit of readers that could have gotten it elsewhere. + +## Conversation language + +The proposal: record the conversation's language, because language selection can +change system prompting, safety behavior, and localization. + +The condition is real, and it is already met somewhere else. A session's system +prompt lives inside `StoredSessionExecutionPlan`, which is opaque `plan_bytes` +plus a digest, immutable for the life of the session. If language drives +prompting, it is *already* durable, inside the plan, and it is already covered by +replay because the plan digest is. + +Adding a `language` field alongside it produces two fields for one fact. They can +disagree, and the one that disagrees is the one a caller trusted. A session +whose plan was built for one language and whose language field says another is a +session where neither value can be relied on. + +If language only drives display, it is a projection concern and belongs in a read +model, where it can change without becoming history. + +Nothing in the current catalog conditions durable behavior on a language value. + +**When this reverses:** when language becomes a thing that can change mid-session +independently of the execution plan. At that point it is a per-turn fact, not a +session preference, and it should be recorded per turn. A mutable +session-level language would be the worst of the three options: durable enough to +be trusted, mutable enough to be wrong for the turns that came before it. + +## External work identity + +The proposal: record an external work identity, so an ACP work request that +reconnects resumes under the same identity. + +The session already carries identities at every level a fold rule uses: turn id, +message id, tool call id, tool execution id, operation id, and delegation ids. +Above them, the envelope carries correlation and causation headers, and +[Event Metadata](./event-metadata.md) is explicit that correlation is what +headers are for. + +An external identity that no invariant reads is correlation. It gets translated +at the boundary, onto the header where correlation lives, and the session's own +identifiers stay the things the aggregate reasons about. Admitting it into the +payload would mean the domain's invariants become sensitive to an identifier +minted by a protocol adapter, which is precisely the coupling the boundary +exists to prevent. + +**When this reverses:** when an external identity determines an outcome the +aggregate must enforce. Concretely: if two work requests arriving under the same +external id must be deduplicated by the decider, then the id is a precondition, +and a precondition belongs in the payload. Until then it is metadata that happens +to be interesting. + +## Tool-specific telemetry + +The proposal: record web fetch and search telemetry, such as cache hit, HTTP +status, response size, and duration. + +The mechanism already exists and needs nothing added. A tool returns +`ToolCallResult.artifact_ref`, and every `ArtifactRef` carries a required `mime`. +A web fetch tool can define its own media-typed result shape, publish it, and put +whatever telemetry it wants in there. Nothing in the session domain has to know +what an HTTP status is. + +The cost of the alternative is not schema size. It is that the generic session +schema would acquire web semantics, and the next tool would ask for its own +fields on the same grounds, and the catalog would slowly become the union of +every tool that ever shipped. + +**The promotion rule**, which is the actual deliverable here: a field moves from a +tool's own result shape into the session catalog when *multiple* tools need it +and read models need its semantics to be stable across them. Duration qualified +under that rule and is already on `ToolCallCompleted`. Cache-hit and HTTP status +do not: one tool needs them, and no projection folds them. + +## Shapes weighed and rejected + +The three sections above are about fields. These are about designs: ways of +laying out a session store that appear in other systems and are deliberately not +used here. Each is grouped under the property it trades away, because the +property is the reusable part. A future proposal that trades away the same +property is the same decision arriving under a new name. + +### Rebuildable state stays rebuildable + +**Authoritative counters on a manifest.** History length, token totals, byte +counts, and last-sequence numbers are projection data. Stored as authority they +can drift from the log they summarize, and a summary that disagrees with its +source is worse than no summary, because the reader has no way to tell which one +is lying. They stay derived and rebuildable. + +**Derived staleness inside an immutable event.** Whether a file is still current +is a fact about the world that changes after the event is written. Written into +the event it is either wrong later or it forces a rewrite of history to stay +right. Freshness lives in projections, where it is allowed to change. + +### The log is append-only and never truncated + +**History replacement events.** A `started` / `chunk` / `committed` sequence that +swaps out prior history is appropriate for replacing a local canonical file. It +is not appropriate here, because +[ADR#0035](../adr/0035-session-store-decider-aggregate.md) keeps the +authoritative log append-only and represents compaction as a self-sufficient +marker rather than as a rewrite. Bulk import that needs chunked publication is an +infrastructure import protocol, not a history-rewriting session event. + +**Usage checkpoints in the session log.** Sampled logs from stores that do this +are dominated by usage events, and facet 7 means every one of them is kept +forever. Settlement is a downstream ledger with its own retention, which is why +it lives in its own domain. The general form of this rule: anything emitted once +per interval cannot be an event in a log that is never truncated. + +### A fact is recorded at the granularity it happened + +**Turn-granular history commits.** Committing once per turn loses the in-flight +assistant and tool facts that a crash lands in the middle of, and it forces an +interrupted turn to be represented as one compound record describing several +things that did and did not happen. Facts are committed as they occur. + +**A compound interrupted-turn record.** The same problem from the read side. An +interruption is expressible as typed assistant and tool terminal facts plus the +operation ledger, where each part says exactly what it knows. A single record +covering all of it has to encode absence positionally, and absence encoded +positionally is the failure mode described in +[Session Tool Effects](./session-tool-effects.md). + +### A binding is immutable, so a change is a new session + +**Workspace rebind.** The execution plan and the workspace binding are immutable +for the life of a session. Rebinding means the events before the rebind describe +work in a place the session no longer claims to be. Continue through a new +session or a fork. + +**Session-level preference mutation.** What is recorded is the settings each +generation actually used, which is a per-generation fact that stays true. A +mutable session-level preference is durable enough to be trusted and mutable +enough to be wrong for every turn that preceded the change. + +### Content goes out of line, addressed by its digest + +**Inline file pre-images.** Carrying prior file content inline is the single +largest cost in stores that do it. It bloats events and every checkpoint folded +from them, and it puts the bytes in the one place erasure cannot reach, because +the log is never truncated. Pre-images are claim-checked and content-addressed +like every other payload of unbounded size. + +### Nothing assumes a single machine + +**Filesystem locks, stat fingerprints, and absolute paths.** These solve +single-machine file ownership. The equivalents here are JetStream write +preconditions, tenant-aware subject resolution, immutable identities, and scoped +object store references. + +**Fixed numeric size limits copied from another implementation.** Limits come +from configured policy and from live NATS and object store limits, which are +deployment facts rather than schema facts. What is worth keeping from the other +implementation is the checked arithmetic and the bounded reads, not its +constants. + +### Relationships are typed events; indexes are projections + +**Relationship truth held outside the session streams.** A parent and child +ownership edge is a domain fact and stays a typed event in the streams that own +it. A relationship index may exist, but only as a projection, so that it can be +discarded and rebuilt without losing the edge. + +### The public contract is versioned and strictly valid + +**Unversioned or lenient public JSON.** A public projection carries its own +version at the top level, not only on a nested object, and it emits JSON that +survives a strict parser. Reusing an older internal shape as the public one is +the specific failure +[ADR#0060](../adr/0060-session-query-contract-separate-from-projection.md) +exists to prevent. + +### Append time is the occurrence time unless the two can differ + +**A creation timestamp on `SessionStarted`.** +[ADR#0035](../adr/0035-session-store-decider-aggregate.md)'s event-time policy +treats append time as transport metadata and adds a payload occurrence time only +when the external occurrence can differ from the append. Platform session +creation *is* the creation append, so a payload timestamp would be a second +field for one fact. This reverses if imported or externally created sessions +acquire a domain occurrence time distinct from when they were appended. + +**A timestamp on every tool result.** The same rule. A locally completed tool +result occurs at its append. An occurrence time is warranted only for a delayed +external result where the two can meaningfully differ, and that case wants its +lifecycle modeled explicitly rather than a timestamp added generically. See +[Session Detached Work](./session-detached-work.md) for the shape that case +actually takes. + +## Layout + +No protos. That is the point. + +## Status + +These are decisions, not deferrals. The three declined fields each name the +specific condition that would reverse them. The rejected shapes are grouped by +the property they trade away, so a proposal that trades the same property can be +recognized as the same decision rather than re-argued from scratch. diff --git a/docs/architecture/session-structured-diff.md b/docs/architecture/session-structured-diff.md new file mode 100644 index 0000000000..644690ff52 --- /dev/null +++ b/docs/architecture/session-structured-diff.md @@ -0,0 +1,98 @@ +# Session Structured Diff + +A review UI wants to highlight changed lines without fetching both versions of +every file. This page documents the artifact that carries that, and why it is an +artifact rather than an event. It documents the protobuf contract that exists +today. There is no Rust implementation yet. + +See [Session Artifacts](./session-artifacts.md) for how the bytes are stored and +read. + +## It is artifact payload, not schema + +`DiffSummary` already had the right shape: exact line counts inline, and the +rendered diff out of line behind a claim-check. What was missing was a typed form +for what sits behind that claim-check, so a reviewer does not have to parse +unified diff text to know which lines changed. + +Putting hunks on `FileChanged` was the alternative and it is wrong for a reason +that has nothing to do with size. How much surrounding context to show is a +presentation decision that changes when a review tool changes. Encoded into +events, every such decision becomes permanent history in a log that is never +truncated ([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7). +The domain would be carrying a UI's opinion about context lines forever. + +It lives in its own subtree, `sessions/diff/v1alpha1`, and imports nothing from +the write side ([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet +3). A diff format moves on a review tool's schedule, and nothing in the session +domain should have to move with it. + +## The counts are not recomputed from the hunks + +This is the trap. Given a structured diff, counting added and removed lines looks +like something a reader can just do, which would make `DiffSummary.added_lines` +redundant. + +It is not, because `DiffSummary.truncated` exists. The artifact may omit hunks +while the inline counts stay exact. A reader that recounts from the hunks of a +truncated diff gets a smaller number and is confidently wrong, and the failure is +silent: two fields for one fact, and the one that disagrees is the one the caller +trusted. + +The inline counts stay authoritative. The artifact is for showing, not for +counting. + +## The marker is the kind, not the first character + +`DiffLine.text` holds the line without its leading `+`, `-`, or space, and +`LineKind` says which it was. + +A renderer that strips one character off the front of a line and assumes it was +punctuation will eventually strip a character that was content. Making the marker +a typed field means that never comes up. + +`old_line` and `new_line` are absent rather than zero when the line does not +exist on that side, so "this line did not exist before" cannot be read as "line +zero". + +## Elision is a line, not a gap + +`LINE_KIND_ELIDED` stands for a run of omitted lines and carries `elided_count` +instead of text. + +Without it, a truncated diff renders two distant regions as adjacent code, which +is not a missing detail but an actively misleading picture of the file. A reader +looking at the result cannot tell that anything was left out. + +## It says what it is, on its own + +`format_version` and `truncated` are both on the artifact, duplicating what the +claim-check and `DiffSummary` already imply. + +That is deliberate. An artifact outlives the reference that found it. A stored +diff read years later through a generic artifact path has to be able to say what +it is and whether it is complete without the `mime` string and the `DiffSummary` +that pointed at it. `format_version` is incremented when the meaning of an +existing field changes, not when fields are added. + +## Layout + +`proto/trogonai/session/sessions/diff/v1alpha1/structured_diff.proto` + +| Type | What it settles | +| --- | --- | +| `StructuredDiff` | the parsed diff, self-describing and versioned | +| `DiffHunk` | one changed region with its context | +| `DiffLine` | one line, with its side positions | +| `LineKind` | what the line represents, including what is not there | + +Discriminated by `ArtifactRef.mime`, which is required on every `ArtifactRef` and +is the media-type mechanism the artifact contract already uses. + +## Status + +Shipped: `structured_diff.proto`, lint-clean, formatted, building, and generating +Rust bindings reachable at `trogonai_proto::session::sessions::diff_v1alpha1`. + +Not shipped: the differ that produces it and the media type string it is +published under. diff --git a/docs/architecture/session-terminal-replay.md b/docs/architecture/session-terminal-replay.md new file mode 100644 index 0000000000..36b92d6e32 --- /dev/null +++ b/docs/architecture/session-terminal-replay.md @@ -0,0 +1,208 @@ +# Session Terminal Replay + +A long command interleaves stdout and stderr across millions of writes. The +session log records a claim-check to the captured output and never the output +itself. This page documents the shape of that capture, what a reader is allowed +to conclude from it, and where it attaches on the write side. It documents the +protobuf contract that exists today. There is no Rust implementation yet. + +See [Session Artifacts](./session-artifacts.md) for how the bytes are read and +checked, and [Session Aggregate](./session-aggregate.md) for the events involved. + +## Why this is an artifact and not events + +An event per output chunk would put the size of the log at the mercy of the +noisiest command that ever ran on it, permanently, because nothing ever leaves +the log ([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7). +Every reader that folds the session would pay for it forever, including readers +that never render a terminal. + +So the capture is one immutable, content-addressed blob referenced by +`CommandOutputReplayRef`, and the whole of item 9's machinery applies to it: +bounded range reads, chunk-hash verification, and the availability vocabulary +for when the bytes are gone. + +## It attaches to the execution record, not the transcript + +`CommandOutputReplayRef` sits on `ToolCallCompleted` beside `CommandTermination`, +and deliberately not inside `ToolCallResult`. + +The reason is the one already written on `CommandTermination`: `ToolCallCompleted` +owns the execution and audit fold, while `ToolCallResult` owns the +provider-visible transcript the model actually received. Those two routinely +differ, because what reaches the model is truncated, summarized, or both. Raw +captured output placed in the replay shape would hand a later turn context that +the original turn never had, which is the same failure an exit code in the +transcript would be. + +It goes on the completion and not the failure for the reason `termination` does. +A command killed by a timeout ran, so it completes with a signal termination and +has output; a command that never started is a `ToolCallFailed` and has none. + +`CompleteToolCall` carries the same field, and the capture is expected to be +sealed and stored before the command is issued. A decider that had to write 40 MB +before it could append would be one whose append latency is set by the noisiest +command in the system. + +## Frames are a fact about the reader loop + +`ReplayFrame` is one contiguous run of bytes the capturer read in one go. It is +not a line, not a `write()` by the process, and not a flush. + +This matters because a renderer that treats frames as lines will split a line +that happened to arrive in two reads, and it will split it in a different place +on a fast machine than on a slow one. The framing exists to preserve order and +stream attribution, and nothing else should be read out of it. + +Payload bytes are stored raw. Not decoded, not normalized, and specifically not +stripped of control sequences, because a terminal replay with the escape codes +removed is replaying something the terminal never showed. Decoding is the +renderer's decision, and it gets to make it more than once. + +## Capture mode decides what the ordering is worth + +This is the field most likely to be ignored and the one most likely to make a +UI lie. + +`CAPTURE_MODE_SEPARATE_PIPES` means stdout and stderr were read from two pipes. +Stream attribution is exact. The interleaving is not: the child's own buffering +decides when each pipe becomes readable, so a line written to stderr before a +line written to stdout can easily be captured after it. A renderer may color the +two streams and must not present their relative order as the order the process +produced them in. + +`CAPTURE_MODE_MERGED_TERMINAL` means both went to one terminal or one pipe. The +interleaving is the process's own and is exact. Stream attribution is gone, and +every frame says `REPLAY_STREAM_MERGED`, because by the time the capturer saw +the bytes there was nothing left to distinguish. A renderer must not infer +stderr from content to fill the gap. + +Neither mode is the better one. They lose opposite things, the choice is made at +spawn time, and a renderer cannot see that choice unless the capture records it. +Which is why it is a required field rather than a default. + +## Order is not timing + +`TIMING_FIDELITY_ORDER_ONLY` is the common case, and it is stated rather than +inferred because a replay UI that animates untimed frames is inventing pacing and +presenting it as a recording. + +`TIMING_FIDELITY_CAPTURE_ELAPSED` means frames carry an elapsed duration, and the +name is deliberate: it is when the *capturer* observed the frame, not when the +process wrote it. Pipe buffering, scheduler delay, and the capturer's own read +loop all sit in between. It is close enough to play back at speed and it is not +evidence of when anything happened. + +## Which end went missing + +`ReplayCompleteness` is not `ArtifactRef.truncated`, which says a preview is +shorter than its content. This says the content is shorter than what the process +emitted, and it names which end is gone, because for a command log that is the +entire question. Losing the tail loses the failure. Losing the head loses what +was run. + +`TRUNCATION_SHAPE_UNSPECIFIED` is not complete. A reader that meets a shape it +does not recognize must treat the capture as of unknown completeness rather than +whole. + +`dropped_byte_count` and `dropped_frame_count` are optional, and absent means +dropping occurred and was not counted, which a fixed-size ring buffer that +overwrites without accounting cannot avoid. They are left unset rather than +reported as zero, because zero here would say nothing was lost. + +Frame sequence numbers are the capturer's original count and are never compacted +when frames are dropped, so a `MIDDLE_DROPPED` gap is visible in the frames +themselves. Renumbering to stay contiguous would destroy the only evidence +inside the artifact that anything is missing. The header field is what lets a +reader know to expect a gap without scanning for one. + +## The index is what makes a range read usable + +Range reads are byte-granular. Frames are variable-length. A read into the middle +of the frame region lands mid-frame, with nothing in the bytes to say where the +next boundary is, so without an index the only correct way to reach frame one +million is to parse the previous 999,999. That is the cost keeping the output out +of the log was supposed to avoid, reintroduced one layer down. + +`ReplayIndex` is a sparse trailer. Sparse, because an entry per frame is an index +whose size grows with the output it indexes, which is the original problem with +more steps; a reader seeks to the nearest preceding entry and scans forward a +bounded distance. A trailer, because a capturer streaming a running process does +not know the index until the process exits and so cannot write it as a header. + +Its offset and length are recorded on the log, so the first read is a bounded +range read straight at the index, rather than a seek relative to an +end-of-object the artifact store might report differently than the log does. + +`ReplayIndexEntry` carries three offsets that are not redundant, because they +answer different questions and converting between them means parsing the frames: + +- `byte_offset` is what a range read takes. +- `frame_sequence` is what a gap shows up in, which is why it is recorded rather + than computed as entry position times a stride. +- `output_byte_offset` is what a UI scrolls and measures in, since a user + positions themselves in output and not in framing overhead. + +`elapsed` is the fourth, present only for a timed capture, and it is what makes +seeking by time possible without reading anything. + +`ReplayIndex` repeats `frame_count` and `output_byte_count`, which are also on +the event. That repetition is the point, and it is the same rule as the artifact +chunk manifest: a reader that has fetched only this trailer can check it against +the log before trusting a single offset in it, and the log is the copy the +artifact store did not supply. An index that disagrees with the event is not a +stale index, it is the wrong artifact or a damaged one. + +## What survives erasure + +Every fact a reader needs to describe the capture is on the log rather than only +inside the artifact: capture mode, timing fidelity, completeness, frame count, +output byte count. + +So when the bytes are erased ([Session Artifacts](./session-artifacts.md)), the +session can still say that the command produced 2.1 million frames and 40 MB, +was captured through a terminal, and was complete. That is the whole point of +separating artifact byte lifecycle from log retention, and it only works if the +summary was never stored exclusively in the thing that gets deleted. + +## Layout + +Two homes, split the way `content_chunks.proto` and the `artifacts` subtree are +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 3). + +The write side records where the capture is and what it is worth: + +- `trogonai/session/sessions/v1alpha1/command_output_replay.proto`: + `CommandOutputReplayRef`, `CaptureMode`, `TimingFidelity`, + `ReplayCompleteness`, `TruncationShape`. +- `output_replay` on `ToolCallCompleted` and `CompleteToolCall`, field 9. + +The read side describes the bytes inside it: + +- `trogonai/session/sessions/replay/v1alpha1/frame.proto`: `ReplayFrame`, + `ReplayStream`, and the byte layout of format version 1. +- `trogonai/session/sessions/replay/v1alpha1/index.proto`: `ReplayIndex`, + `ReplayIndexEntry`. + +The artifact is two regions. The frame region runs from offset 0 and holds +frames back to back, each a little-endian `uint32` byte length followed by that +many bytes of a serialized `ReplayFrame`. The index region is the trailer, +holding a serialized `ReplayIndex`, located by `index_offset` and `index_length` +on the event. + +## Status + +Shipped: the three protos above and the two field additions, lint-clean, +formatted, building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::replay_v1alpha1`. + +Not shipped: the capturer, the spool-and-seal path, the framing writer, the +index builder, the renderer, and the replay-artifact byte quota, which belongs +with the rest of the artifact admission limits rather than here. + +`format_version` is on the event as a number rather than parsed out of the +artifact's media type, because a reader deciding whether it can parse these +frames should not be doing string surgery on a MIME parameter to find out. There +is exactly one version and the field exists anyway, since the alternative is +adding it after the first capture that needs it, when every existing artifact +already lacks it. diff --git a/docs/architecture/session-title-and-preview.md b/docs/architecture/session-title-and-preview.md new file mode 100644 index 0000000000..881967a0af --- /dev/null +++ b/docs/architecture/session-title-and-preview.md @@ -0,0 +1,111 @@ +# Session Title and Preview + +The first prompt gives a session a name. A later rename overrides it. A redaction +removes the message the first name came from. This page documents the precedence +that resolves a title, why a preview invalidates differently from a stored +string, and what absence means. It documents the protobuf contract that exists +today. There is no Rust implementation yet. + +See [Session Query Contract](./session-queries.md) for where these appear and +[Session Presentation Caches](./session-presentation-cache.md) for the +coordinates they invalidate against. + +## The precedence, published + +The projection resolves a title in one order, always: + +1. the latest effective `SessionRenamed`, if one survives +2. otherwise a title derived from the first effective user message +3. otherwise a server-supplied fallback + +`TitleSource` says which rule fired. That is what makes the result checkable, and +it lets a client style a guess differently from a name a human chose. + +`title` is always set. When there is nothing to show it holds the fallback rather +than an empty string, because a picker that has to invent a name is a picker +where two clients invent different ones. + +## The two sources invalidate differently + +This asymmetry is why `TitleSource` is an enum and not a `title_is_explicit` +bool. + +A derived title is a function of effective history. Rewinding past the first user +message changes it. Redacting that message changes it. It is not a stored value +that happens to have been computed once; it is a projection that has to be +recomputed whenever effective history moves. + +An explicit title is an authoritative fact of its own. `SessionRenamed` is an +event, and rewinding or redacting the message that inspired the original name +does not touch it. + +What an explicit title does not survive is being redacted itself. When that +happens the resolution falls back down the same precedence rather than keeping a +name whose source no longer exists, and `TitleSource` changes to say so. A title +that outlived its own source event would be exactly the case where a redaction +did not take. + +## Preview follows privacy, not just recency + +`SessionPreview` is derived from effective history, and that is the whole reason +it belongs in the projection rather than in a column. + +Rewind masks ordinals. Redaction removes content from ordinals that stay. Either +can take away the very message a preview was cut from. A preview cached without +regard for that puts deliberately destroyed text back on a screen, which is a +privacy failure and not a staleness annoyance. + +Its validity therefore tracks `effective_history_revision` and +`privacy_revision`, the same two coordinates a +[presentation cache](./session-presentation-cache.md) binds against. A cached +preview whose binding fails those two must be discarded, not shown as merely +older. This is the same argument that makes `CACHE_USABILITY_APPENDABLE` gate on +the revisions rather than on the watermark: a lower watermark is only a prefix of +a higher one if history was append-only in between, and none of these operations +is. + +## Absence has several causes and they are not the same + +`SessionPreview` is always set, including when there is no preview, because the +reason there is none is what a caller needs in order to render the row honestly. + +| Availability | What the row should say | +| --- | --- | +| `AVAILABLE` | the excerpt | +| `EMPTY` | nothing was authored | +| `NON_TEXTUAL` | an image-only or attachment-only opening | +| `REDACTED` | content existed and was deliberately removed | +| `WITHHELD` | content exists and this caller may not see it | + +Collapsing these into an empty string tells a user a session is empty when it may +be one they are not cleared to see, or one whose opening was removed on purpose. +"No messages" is a lie about both. + +`WITHHELD` is per caller, like `ArtifactCompletenessView.hidden`: two readers of +the same session can get different answers, and the difference is authorization +rather than content. `truncated` marks a cut excerpt, so a renderer never +presents a fragment as a whole message. + +## Layout + +`proto/trogonai/session/sessions/queries/v1alpha1/session_view.proto` + +| Type | What it settles | +| --- | --- | +| `TitleSource` | which precedence rule produced the title, and how it invalidates | +| `SessionPreview` | the excerpt, and whether it is a cut | +| `SessionPreviewAvailability` | why there is no excerpt | + +`SessionPreview` is on `SessionSummary`, so it is on the list row. That is +deliberate for the same reason `RecoveryProvenanceView` is: a picker is where the +decision gets made, and information that only appears after opening a session +arrives after it stopped mattering. + +## Status + +Shipped: the preview types and the documented precedence, lint-clean, formatted, +building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::queries_v1alpha1`. + +Not shipped: the projection that derives titles and previews, and the truncation +bound it applies. diff --git a/docs/architecture/session-tool-effects.md b/docs/architecture/session-tool-effects.md new file mode 100644 index 0000000000..0ad18a009e --- /dev/null +++ b/docs/architecture/session-tool-effects.md @@ -0,0 +1,143 @@ +# Session Tool Effects + +A tool call is not one effect. A search touches thousands of filenames and reads +none of them. A copy creates a file that is not new content. A batch edit over +ten targets succeeds for eight. This page documents three additions that let a +completion say what actually happened, and the volume constraint that shapes all +three. It documents the protobuf contract that exists today. There is no Rust +implementation yet. + +See [Session Aggregate](./session-aggregate.md) for `ToolCallCompleted` and +`FileChanged`, and [Session Artifacts](./session-artifacts.md) for the +claim-checks these lean on. + +## The constraint that shapes all of it + +`ResourceObservation` already carries the rule, in its own header: record an +observation only for a resource whose content actually entered the model's +context, never for every path a search walked. Reads outnumber writes by more +than an order of magnitude, and the log is never truncated +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7). + +Everything below obeys that. None of these additions is per path. + +## Namespace access is not content access + +A grep across a secrets directory that returns no matches reads nothing. It +produces no `ResourceObservation`, correctly. And yet something happened that a +compliance reviewer has to be able to see: the agent learned those files exist +and what they are called. + +The tempting fix is to weaken `ResourceObservation` so it can also mean "saw the +name". That destroys both questions. "Did the agent read this file" and "did the +agent see this file's name" have different answers and different consequences, +and a record that means either answers neither. + +`ResourceAccessRecord` is the separate fact. It is per scope, never per path: + +- `scope` is the extent of exposure, a directory or a search root +- `matched` is what came back, which is the number that matters, because four + hits for "password" in a secrets directory is a different disclosure from four + hundred files existing there +- `traversed` is what was walked to produce that answer, counted separately + because reading a filename to reject it is still reading the filename +- `complete` says whether the scope was covered, so a truncated enumeration is + never read as a full inventory + +The path list itself, when it is worth keeping, goes out of line in `enumerated` +as a claim-check. That is the volume argument again, and it has a second effect +worth naming: the list is erasable under a deletion request while the counts +survive it. The audit fact that an enumeration happened stays permanent even +after what was enumerated is gone. + +`ResourceAction` separates the actions that expose names from the ones that +expose or alter content, because a real policy is written that way. "This agent +may find files here but may not open them" is a rule deployments have, and it is +inexpressible without `LIST` and `SEARCH` being distinct from `READ`. + +## A copy is not a create, and not a rename either + +`FileChanged` had four kinds, and a copy had to be recorded as a create. That +loses the fact that makes it reviewable. "A new file appeared at +`deploy/prod.yaml`" and "`deploy/staging.yaml` was duplicated to +`deploy/prod.yaml`" are different events, and the second raises a question worth +raising. + +The available shortcut was to reuse `previous_path`, since both a rename and a +copy name an earlier location. They make opposite claims about it. After a rename +the previous path is gone; after a copy the source is still sitting there, +unchanged. Overloading the field would report a file as moved when it was not, so +`previous_path` stays rename-only and `CopySource` is its own field. + +`FILE_CHANGE_KIND_COPIED` replaces `CREATED` for the destination rather than +appearing alongside it, so the destination has exactly one kind and two facts +about one change cannot disagree. The source emits nothing, because nothing +happened to it. + +`CopySource.source_digest` is what makes the copy checkable later, on the same +reasoning as `ResourceObservation`: without it, a reader can see that +`prod.yaml` came from `staging.yaml` but not whether it came from the +`staging.yaml` that exists now or from a version since edited. + +## Eight of ten is a completion, not a failure + +A batch edit over ten files that applies eight and fails two is a +`ToolCallCompleted` with `TOOL_CALL_RESULT_STATUS_APPLICATION_ERROR`. It is never +a `ToolCallFailed`. + +The reason is not classification taste. Eight files really changed. Those changes +are already `FileChanged` facts on the log and no result status retracts them. A +`ToolCallFailed` asserts that nothing was applied, and a reader that folds it +that way will believe a workspace is in a state it is not in. + +`failed_targets` records only the failures. The successes are deliberately +absent, because they exist as `FileChanged` and a second record of the same +change is a second thing to keep consistent through rewind and redaction. What no +other event can express is the negative: that a target was named, attempted, and +did not happen. Without it, a reader seeing eight changes for a ten-file request +has to reconstruct the gap from tool arguments, which is exactly the inference a +typed record removes. + +`targets_attempted` is the denominator. It is recorded rather than inferred, +because zero targets attempted and no target list are different situations that +an empty list cannot tell apart. + +`TargetFailureReason` is typed because retry soundness differs by reason. A +permission fault is durable and a retry repeats it. A failed precondition means +the resource moved under the agent, and a retry against fresh content may +succeed. `NOT_ATTEMPTED` is neither: it says the call stopped before reaching +this target, which is not a fact about the target at all, and it exists so an +unreached target is never read as a rejected one. + +`target_uri` is a URI rather than a workspace-relative path because a +multi-resource tool's targets are not always files, and a failure against a +remote resource has no path to record. + +## Never a failed FileChanged + +The rule these share: `FileChanged` means a file changed. A target that failed +did not change, so it produces no `FileChanged` under any circumstance, no matter +how convenient a `success: false` flag would be for a renderer. The moment that +flag exists, every consumer of file history has to remember to filter on it, and +the ones that forget will report changes that never happened. + +## Layout + +| File | What it settles | +| --- | --- | +| `v1alpha1/resource_access.proto` | namespace access as distinct from content access | +| `v1alpha1/copy_source.proto` | where copied content came from, and what it hashed to | +| `v1alpha1/target_outcome.proto` | which targets of a multi-target call did not apply | + +They attach at `ToolCallCompleted.accessed`, `ToolCallCompleted.failed_targets` +with `targets_attempted`, and `FileChanged.copied_from`, with the matching fields +on `CompleteToolCall`. + +## Status + +Shipped: all three protos plus `FILE_CHANGE_KIND_COPIED`, lint-clean, formatted, +building, and generating Rust bindings reachable at +`trogonai_proto::session::sessions::v1alpha1`. + +Not shipped: any tool that populates them. A tool runtime has to decide what its +scope is and count its own traversal, and nothing does that yet. diff --git a/docs/architecture/usage-settlement-ledger.md b/docs/architecture/usage-settlement-ledger.md new file mode 100644 index 0000000000..db8b6d4046 --- /dev/null +++ b/docs/architecture/usage-settlement-ledger.md @@ -0,0 +1,161 @@ +# Usage Settlement Ledger + +A billing consumer reads recorded usage and turns it into charges. It publishes +a charge and the acknowledgment never arrives. This page documents the ledger +that makes the next step safe. It covers the protobuf definitions that exist +today. There is no Rust implementation yet. + +See [Session Aggregate](./session-aggregate.md) for where usage is recorded and +[Session Crash Boundaries](./session-crash-boundaries.md) for the general shape +of an operation whose outcome was never observed. + +## Why this is not in the Session domain + +Session records what was consumed. A billing consumer reads that and settles it. +The retry state of the second job is the consumer's problem. + +Publishing settlement progress back into a session stream would put a downstream +system's bookkeeping into a log that is never truncated +([ADR#0035](../adr/0035-session-store-decider-aggregate.md) facet 7), so a +transient provider outage would leave permanent noise in the history of every +session it touched. The ledger is the consumer's own durable state, in its own +domain, at `proto/trogonai/usage/settlement/v1alpha1/`. + +## The record is written before the charge + +A ledger written after a successful publish cannot describe the failure it +exists to describe. If the process dies between publishing and recording, the +only evidence that a charge might exist is gone, and the retry has nothing to +consult. + +So intent is durable first, and `SettlementState` is ordered around that: + +| State | What a retry may assume | +| --- | --- | +| `UNSPECIFIED` | Nothing. Treat as `UNKNOWN`. | +| `INTENDED` | No charge exists. | +| `IN_FLIGHT` | A publish is running in this process. | +| `UNKNOWN` | A publish was attempted and its outcome was never observed. | +| `SETTLED` | The provider confirmed. Terminal. | +| `REJECTED` | The provider refused and said so. Terminal. | +| `ABANDONED` | Closed by a recorded decision. Terminal. | + +`INTENDED` is the only state that lets a consumer conclude no charge exists, and +it holds only because the move to `IN_FLIGHT` is itself durable and happens +before the publish call. A crash cannot skip past it. + +`IN_FLIGHT` is not durable in the sense a reader might expect. A consumer +recovering from a crash has no in-progress calls, so every record found in that +state on startup becomes `UNKNOWN`. Its useful life is one process lifetime. + +The zero value is the one that blocks a blind retry, because the failure this +whole ledger prevents is a retry that assumes nothing happened. + +`ABANDONED` is reachable only through an incident, so nothing in the automated +path can reach it. A consumer able to abandon a charge on its own is one that +quietly stops billing under sustained provider failure. + +## The idempotency key comes from the usage, never the attempt + +`settlement_id` is derived deterministically from the usage fact: session, +ordinal, meter. This is the single property that makes double charging +impossible rather than unlikely. A retry recomputes the same key from the same +inputs, so the provider sees the same request it may already have processed. + +A key minted per attempt would make every retry a new charge, and the retry path +is precisely the path a lost acknowledgment forces a consumer down. That is why +`UsageRef` points at the ordinal that recorded consumption rather than at a +running total: totals are derived and can be recomputed differently, and the +fact that a specific ordinal recorded a specific quantity cannot change. + +`ProviderReceipt.deduplicated` records when the provider reported a repeat under +the same key. It is worth keeping rather than discarding as a suppressed +success, because it is direct evidence that an earlier attempt landed and its +acknowledgment was lost. It is the difference between a system that is retrying +correctly and one that is about to be found out at reconciliation. + +## The watermark and the ledger move independently + +`ConsumerCheckpoint.processed_watermark` says how far the consumer has read. +The ledger says what those reads came to. They are tracked separately on +purpose: if the watermark could not advance past an unresolved settlement, one +charge stuck behind a provider outage would stop billing for everything after +it, and a short outage would become a backlog the size of the busiest tenant. + +The watermark does have one ordering rule. It advances only after the ledger +records exist for everything below it. Advancing first would lose usage on a +crash, and that is the one failure this ledger cannot detect afterwards: an +unrecorded charge leaves nothing behind to reconcile against. + +`unknown_settlement_count` is broken out from `open_settlement_count` because it +is the number that means money may have moved without anyone knowing, and +burying it in a general open count is how it stops being looked at. + +## Recovery scans are bounded, and say what they missed + +A recovery pass that scans the whole ledger gets slower exactly as the system +gets busier, so the pass meant to run during an incident is the one that stops +finishing during an incident. + +`ScanOpenSettlementsRequest` bounds it three ways: by state, by idle time, and +by source position. `oldest_open_watermark` on the checkpoint is what makes the +third one useful, since it lets a sweep be proportional to what is open rather +than to the ledger's size. `idle_for` matters for the automated path +specifically: a settlement published a second ago is not stuck, it is in flight, +and a recovery pass that republishes it is competing with the attempt already +running. + +`ScanCoverage` is always present, including on an exhaustive scan. An operator +reading an empty page needs to know whether nothing is open or the scan ran out +of budget, and those are identical without it. A non-zero `unreadable_count` +means unresolved settlements exist that this scan cannot name, so the sweep +cleared nothing. + +## Reconciliation is a question, not a retry + +`ReconcileSettlement` asks the provider what actually happened. It exists so a +consumer facing `UNKNOWN` has a move other than publishing again and hoping the +idempotency key holds, and no field on the request can cause a charge. + +The outcome that matters most is `PROVIDER_CANNOT_SAY`, usually because the key +is older than the provider's retention for idempotency records. It is reported +separately from `CHARGE_ABSENT` because they differ on the only question that +matters: absent means republishing is safe, and cannot-say means the provider +has forgotten the key that was making it safe. + +The zero value keeps the settlement unresolved, so a reconciliation returning a +variant the caller does not understand leaves the record needing attention +instead of closing it. + +## Rewinding a session does not un-consume tokens + +A session can be rewound, compacted, or redacted, and the ordinal that recorded +usage can leave effective history. The ledger deliberately does not follow. + +Usage is not part of effective history. Tokens that were spent were spent, and a +ledger that tracked effective history would refund real compute every time a +user backed up a turn. What is genuinely ambiguous is whether a removal was a +correction or a privacy action, and that is a question for a person, so it +opens `INCIDENT_KIND_USAGE_RETRACTED` rather than reversing anything. + +## Layout + +`proto/trogonai/usage/settlement/v1alpha1/`: + +| File | Contents | +| --- | --- | +| `ledger.proto` | `UsageRef`, `SettlementRecord`, `SettlementState`, `ProviderReceipt`, `SettlementIncident` | +| `recovery.proto` | `ConsumerCheckpoint`, the bounded scan, `ReconcileSettlement` | + +No `service` definitions, matching the rest of this repo: transport binding is +JSON-RPC over NATS ([ADR#0055](../adr/0055-nats-subject-design-jsonrpc-bindings.md), +[ADR#0056](../adr/0056-canonical-jsonrpc-bodies-over-nats.md)). + +## Status + +Shipped: the two protos above, lint-clean, formatted, building, and generating +Rust bindings reachable at `trogonai_proto::usage::settlement_v1alpha1`. + +Not shipped: the consumer, the ledger store, any provider binding, and the +incident workflow. The contract is the part that has to be right first, because +every mistake it prevents is a mistake that shows up on someone's invoice. diff --git a/docs/glossary/index.md b/docs/glossary/index.md index 45e72062d2..78dd8adc49 100644 --- a/docs/glossary/index.md +++ b/docs/glossary/index.md @@ -46,6 +46,7 @@ entries are the quick reference. - [Admission control](./admission-control) - [Retention watermark](./retention-watermark) - [Command principal](./command-principal) +- [Stream incarnation](./stream-incarnation) ## Agent execution model diff --git a/docs/glossary/stream-incarnation.md b/docs/glossary/stream-incarnation.md new file mode 100644 index 0000000000..da86308084 --- /dev/null +++ b/docs/glossary/stream-incarnation.md @@ -0,0 +1,14 @@ +--- +term: "Stream incarnation" +section: "Event sourcing and the decider" +order: 17 +--- + +# Stream incarnation + +A label on the physical JetStream stream that holds an aggregate's events, +advancing only when the platform rebuilds that stream. It is carried as a token +in the subject, so two incarnations occupy disjoint subject spaces and a writer +holding a position from a retired one cannot reach the live one. Retiring an +incarnation seals it, permanently rejecting writes. See +[ADR#0059](../adr/0059-session-stream-incarnation-fencing.md). diff --git a/docs/research/session-store/products/fx/vs-session-events.md b/docs/research/session-store/products/fx/vs-session-events.md index 8013b857c4..357bce3f3a 100644 --- a/docs/research/session-store/products/fx/vs-session-events.md +++ b/docs/research/session-store/products/fx/vs-session-events.md @@ -400,19 +400,34 @@ model is fine, a rollup in the event is a second source of truth. `last_event_seq` are all recomputable and all capable of drifting from the log they summarise. -## Open questions for the ADR - -- Turn identity: correlator field or explicit `TurnStarted` / `TurnEnded` - events? The second is more faithful; the first is compatible with every - existing event without touching their shapes. -- Are file reads session facts or tool details? The answer decides whether - audit ("what did the agent look at") is a first-class capability or a - log-parsing exercise. -- Is workspace binding part of the session aggregate or part of the opaque - execution plan? If the former, is rebinding supported, and does it produce - an event? -- Does a provider-native escape hatch belong in a canonical event catalog at - all, or should each provider-specific need be modelled explicitly as it - arises? `ThinkingBlock.signature` is the precedent either way. -- Do we need an epoch or authority token distinct from stream sequence, or do - we prohibit stream recreation outright? +## Questions this study opened, and how they were answered + +All five are closed. They are kept here rather than deleted so the comparison +records what it actually changed. + +- **Turn identity: a correlator field, or explicit `TurnStarted` / `TurnEnded` + events?** The correlator. A required `turn_id` correlates conversation, tool, + and file facts without adding events whose only content is a boundary. +- **Are file reads session facts or tool details?** Session facts. + `ToolCallCompleted.observed` records URI, digest or confirmed absence, range, + and completeness, so audit is a fold rather than a log-parsing exercise. A + later pass separated *seeing a name* from *reading contents*, because they are + different compliance questions: see + [Session Tool Effects](../../../../architecture/session-tool-effects.md). +- **Is workspace binding part of the aggregate or part of the opaque execution + plan, and is rebinding supported?** Part of the aggregate, and rebinding is + not supported. The binding is immutable for the life of the session; a change + is a new session or a fork. Recorded in + [Session Schema Boundaries](../../../../architecture/session-schema-boundaries.md). +- **Does a provider-native escape hatch belong in a canonical catalog?** Yes, + under a strict rule. `ProviderBlock` retains unmodelled provider blocks as + write-verbatim, read-never data, inline or via `ArtifactRef`. Read-never is + what keeps it an escape hatch rather than a second schema: a projection may + not mine it. That constraint is precisely why a malformed tool intent needed + its own typed event, in + [Session Provider Faults](../../../../architecture/session-provider-faults.md). +- **Do we need an epoch or authority token distinct from stream sequence, or do + we prohibit stream recreation outright?** Neither, as posed. The incarnation + is a token in the subject, so the fence is the address rather than a checked + value, and a retired incarnation is sealed. See + [ADR#0059](../../../../adr/0059-session-stream-incarnation-fencing.md). diff --git a/proto/trogonai/session/sessions/artifacts/v1alpha1/artifact_error.proto b/proto/trogonai/session/sessions/artifacts/v1alpha1/artifact_error.proto new file mode 100644 index 0000000000..1b72f29bf0 --- /dev/null +++ b/proto/trogonai/session/sessions/artifacts/v1alpha1/artifact_error.proto @@ -0,0 +1,44 @@ +edition = "2024"; + +package trogonai.session.sessions.artifacts.v1alpha1; + +// ArtifactError is the failure shape for the artifact read contract. +// +// Only failures to answer belong here. An artifact that is erased, missing, +// corrupt, or hidden is an answer, carried as ArtifactAvailability on a +// successful response, because it is a fact about the artifact the caller +// asked about. Reporting it as an error would make "what happened to this +// artifact" indistinguishable from "the read contract is broken" at exactly +// the moment an operator needs to tell them apart. +message ArtifactError { + ArtifactErrorCode code = 1 [features.field_presence = LEGACY_REQUIRED]; + string message = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// ArtifactErrorCode is why the request could not be answered. +enum ArtifactErrorCode { + ARTIFACT_ERROR_CODE_UNSPECIFIED = 0; + // No such session, or the caller may not see it. Deliberately one code, and + // deliberately not distinguished from permission denial, so that probing + // cannot use the difference to prove a session exists. + ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND = 1; + // The session exists and holds no artifact under this id. This is not the + // same as ARTIFACT_AVAILABILITY_MISSING: here the claim-check itself is + // absent, so nothing was ever promised, whereas MISSING is a promise the log + // made and the store did not keep. + ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND = 2; + // The range is not addressable: an offset past the end of the artifact, or a + // zero length. + ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE = 3; + // Verification was required and the artifact has no chunk manifest, so no + // checkable range of it exists. Refusing here is the whole value of the + // requirement: the alternative is a caller believing it verified a read + // because it asked to. + ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE = 4; + // The requested length exceeds what a single response may carry. The bound is + // deployment-specific, so it is reported rather than encoded in the schema; + // the message carries the accepted maximum. + ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE = 5; + // Malformed request that is none of the above. + ARTIFACT_ERROR_CODE_INVALID_ARGUMENT = 6; +} diff --git a/proto/trogonai/session/sessions/artifacts/v1alpha1/availability.proto b/proto/trogonai/session/sessions/artifacts/v1alpha1/availability.proto new file mode 100644 index 0000000000..55236e6ca8 --- /dev/null +++ b/proto/trogonai/session/sessions/artifacts/v1alpha1/availability.proto @@ -0,0 +1,60 @@ +edition = "2024"; + +package trogonai.session.sessions.artifacts.v1alpha1; + +// Value types for the Session artifact read contract. +// +// These are redefined here rather than imported from the write side on purpose +// (ADR#0035 facet 3). The write side records what happened to an artifact; this +// contract answers what a caller can get right now, and the two change for +// different reasons and on different cadences. + +// ArtifactAvailability is what a caller can expect to read, and why, when the +// answer is not "the bytes". +// +// A claim-check can fail to resolve for reasons that are not interchangeable, +// and collapsing them into a single "missing" is how deliberate destruction +// gets reported as data loss and how a transient storage fault gets reported as +// permanent. Every non-AVAILABLE value here is a distinct operational +// situation with a distinct correct response. +// +// The vocabulary deliberately reuses the Session doctor's +// mismatch/absent/unreadable distinction rather than inventing a second +// taxonomy for the same three facts. +enum ArtifactAvailability { + ARTIFACT_AVAILABILITY_UNSPECIFIED = 0; + // The bytes are readable now. + ARTIFACT_AVAILABILITY_AVAILABLE = 1; + // Destroyed on purpose and recorded as such by ArtifactErased. The + // claim-check and its provenance remain on the log; the bytes are gone and + // are not coming back. This is a correct end state, not a fault, and a reader + // that renders it as damage will send someone looking for a problem that was + // the point. + ARTIFACT_AVAILABILITY_ERASED = 2; + // The store reports no such object, and no erasure was ever recorded. This is + // the one value that means something went wrong: the log says bytes exist + // that do not. + ARTIFACT_AVAILABILITY_MISSING = 3; + // The artifact was recorded as an external reference whose bytes were never + // durably stored. There is nothing to range-read, and there never was; the + // source location may or may not still serve them, which is not this + // contract's claim to make. + ARTIFACT_AVAILABILITY_EXTERNAL_ONLY = 4; + // The object was read and does not match the digest recorded on the log. The + // bytes exist and are not the artifact's, so serving them silently would hand + // a caller content under a claim-check it does not satisfy. + ARTIFACT_AVAILABILITY_CORRUPT = 5; + // The object could not be read. Unlike MISSING this makes no claim about + // whether the bytes exist: a permissions or transport fault against the + // artifact store looks identical from here, and a retry may succeed. + ARTIFACT_AVAILABILITY_UNREADABLE = 6; + // The caller may see that this artifact exists and may not read it. + // + // This is reported, rather than answered as MISSING, only because the caller + // can already see the claim-check in the session's own history. Hiding the + // bytes from someone who is looking at the reference protects the content; + // pretending the reference is dangling would just describe the session + // incorrectly. An artifact belonging to a session the caller cannot see is + // never reachable to be labelled at all. + ARTIFACT_AVAILABILITY_HIDDEN = 7; +} diff --git a/proto/trogonai/session/sessions/artifacts/v1alpha1/chunk_manifest.proto b/proto/trogonai/session/sessions/artifacts/v1alpha1/chunk_manifest.proto new file mode 100644 index 0000000000..57281d24f4 --- /dev/null +++ b/proto/trogonai/session/sessions/artifacts/v1alpha1/chunk_manifest.proto @@ -0,0 +1,34 @@ +edition = "2024"; + +package trogonai.session.sessions.artifacts.v1alpha1; + +// GetChunkManifestRequest asks for the per-chunk digests that make ranges of an +// artifact checkable. +message GetChunkManifestRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string artifact_id = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// GetChunkManifestResponse carries the ordered chunk digests. +// +// The manifest comes from the artifact store, so on its own it proves nothing: +// a store serving wrong bytes can serve a manifest that agrees with them. It +// becomes evidence only when the caller hashes it and compares the result +// against the manifest digest recorded on the event log, which the store did +// not supply. A caller that skips that comparison has verified nothing and +// should say so rather than report a verified read. +message GetChunkManifestResponse { + string artifact_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Hash used for each chunk digest and for the digest over their + // concatenation, for example "sha256". + string algorithm = 2 [features.field_presence = LEGACY_REQUIRED]; + // Size of every chunk but the last, which holds the remainder. + uint64 chunk_size_bytes = 3 [features.field_presence = LEGACY_REQUIRED]; + // Total size of the artifact, so a caller can tell a complete manifest from a + // truncated one before trusting any chunk in it. + uint64 size_bytes = 4 [features.field_presence = LEGACY_REQUIRED]; + // Raw chunk digests in artifact order, one per chunk. The algorithm is on the + // envelope because every entry uses the same one, and a per-entry algorithm + // would be a per-entry opportunity for them to disagree. + repeated bytes chunk_digests = 5; +} diff --git a/proto/trogonai/session/sessions/artifacts/v1alpha1/read_artifact_range.proto b/proto/trogonai/session/sessions/artifacts/v1alpha1/read_artifact_range.proto new file mode 100644 index 0000000000..81d88875a0 --- /dev/null +++ b/proto/trogonai/session/sessions/artifacts/v1alpha1/read_artifact_range.proto @@ -0,0 +1,96 @@ +edition = "2024"; + +package trogonai.session.sessions.artifacts.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/artifacts/v1alpha1/availability.proto"; + +// ReadArtifactRangeRequest asks for a bounded window of an artifact's bytes. +// +// There is no request for the whole artifact and no way to express one. A +// caller that wants all 40 MB issues successive ranges; the transport carries +// JSON-RPC bodies over NATS (ADR#0055, ADR#0056) and has no streaming call, so +// successive bounded reads are the streaming primitive rather than a +// workaround for the absence of one. The practical difference is that the +// bound is always the caller's and always visible, instead of a limit +// discovered when a response fails to fit. +message ReadArtifactRangeRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string artifact_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // First byte requested, counted from the start of the artifact. + uint64 offset = 3 [features.field_presence = LEGACY_REQUIRED]; + // How many bytes are wanted. The server may serve fewer at the end of the + // artifact or under its own cap, and may serve more only to reach a chunk + // boundary when verification was required. What was served is on the + // response; a caller must read it rather than assume it got what it asked + // for. + uint64 length = 4 [features.field_presence = LEGACY_REQUIRED]; + VerificationRequirement verification = 5; +} + +// VerificationRequirement is whether the caller is willing to receive bytes it +// cannot check. +// +// Unspecified means required. The default has to be the strict one: a caller +// that never thought about verification is precisely the caller that will not +// notice unchecked bytes arriving, and a field whose omission silently weakens +// a guarantee is a guarantee only for people who read the schema. +enum VerificationRequirement { + VERIFICATION_REQUIREMENT_UNSPECIFIED = 0; + // Refuse the read rather than serve a range the caller cannot check. A + // requirement that degrades into a warning when it cannot be met is not a + // requirement, so this fails with + // ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE instead of returning bytes + // labelled unverifiable. + VERIFICATION_REQUIREMENT_REQUIRED = 1; + // Serve the range even when it cannot be checked. Appropriate for a preview + // pane and not for anything that will be executed, replayed, or stored + // elsewhere as the artifact. + VERIFICATION_REQUIREMENT_NOT_REQUIRED = 2; +} + +// ReadArtifactRangeResponse carries the served bytes and says what they are +// worth. +message ReadArtifactRangeResponse { + string artifact_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ArtifactAvailability availability = 2 [features.field_presence = LEGACY_REQUIRED]; + // First byte actually served. Equal to the requested offset unless + // verification required aligning down to a chunk boundary. + uint64 offset = 3 [features.field_presence = LEGACY_REQUIRED]; + // The served bytes. Empty for every availability except + // ARTIFACT_AVAILABILITY_AVAILABLE. Its length is the served length; a + // separate length field would be a second copy of a fact the bytes already + // carry, and the copy is what a caller would trust when they disagree. + bytes content = 4; + // Total size of the artifact. This is what makes the response + // self-describing: with the served offset and length, a caller derives + // reaching the end of the artifact from being cut short by the server + // without a flag that could contradict the numbers next to it, and knows + // where to resume without a second call. + uint64 size_bytes = 5 [features.field_presence = LEGACY_REQUIRED]; + RangeVerifiability verifiability = 6 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp observed_at = 7 [features.field_presence = LEGACY_REQUIRED]; +} + +// RangeVerifiability is whether the caller can check what it just received. +// +// It reports what the caller can do, not what the server did, and the +// distinction is the point. A server field reading "verified" would be the +// party under suspicion certifying itself: the only check worth anything here +// is one the caller performs, against a manifest digest that came from the +// event log rather than from the artifact store. So this contract's obligation +// is to serve ranges in a shape that can be checked, and to say plainly when it +// has not. +enum RangeVerifiability { + RANGE_VERIFIABILITY_UNSPECIFIED = 0; + // The served range covers whole chunks, so every byte in it is covered by a + // chunk digest the caller can obtain and check. + RANGE_VERIFIABILITY_VERIFIABLE = 1; + // The artifact was stored without chunk hashing. Nothing about this range can + // be checked short of reading the entire artifact and hashing it. + RANGE_VERIFIABILITY_NO_MANIFEST = 2; + // A manifest exists and the served range does not align to it, because the + // caller allowed an unverifiable read. The partial chunks at its edges are + // not covered by any digest the caller can check. + RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED = 3; +} diff --git a/proto/trogonai/session/sessions/artifacts/v1alpha1/stat_artifact.proto b/proto/trogonai/session/sessions/artifacts/v1alpha1/stat_artifact.proto new file mode 100644 index 0000000000..15b52e0735 --- /dev/null +++ b/proto/trogonai/session/sessions/artifacts/v1alpha1/stat_artifact.proto @@ -0,0 +1,59 @@ +edition = "2024"; + +package trogonai.session.sessions.artifacts.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/artifacts/v1alpha1/availability.proto"; + +// StatArtifactRequest asks what an artifact is, without asking for it. +// +// There is deliberately no field on this request that could cause bytes to be +// returned: no range, no "include content", no size threshold under which the +// content comes along. A caller reaching for metadata about a 40 MB artifact +// must not be able to fetch 40 MB by setting a field wrong, and a reviewer must +// not have to read a value to know a call was cheap. This is the same +// structural argument that gives DiagnoseSession no repair mode. +message StatArtifactRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string artifact_id = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// StatArtifactResponse describes the artifact and what can be done with it. +message StatArtifactResponse { + string artifact_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ArtifactAvailability availability = 2 [features.field_presence = LEGACY_REQUIRED]; + // Short human-readable preview recorded with the artifact; empty when none + // was produced. Present regardless of availability, because a preview is + // recorded on the log rather than stored with the bytes and so survives their + // erasure or loss. For many callers this is the whole answer, and the reason + // a preview is not a range read is that it costs nothing to serve. + string preview = 3; + // True when preview is a truncation of the full content. + bool preview_truncated = 4 [features.field_presence = LEGACY_REQUIRED]; + // Set only for ARTIFACT_AVAILABILITY_AVAILABLE. Every other availability has + // no readable bytes to describe, and a size or digest reported next to one of + // them would describe something the caller cannot obtain. + ReadableContent content = 5; + // When availability was determined. Availability is an observation of an + // external store at a moment, not a durable property of the artifact, and a + // caller acting on it later is acting on a claim that has since expired. + google.protobuf.Timestamp observed_at = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// ReadableContent describes bytes a caller can actually get. +message ReadableContent { + uint64 size_bytes = 1 [features.field_presence = LEGACY_REQUIRED]; + // Decoded media type of the stored bytes. + string mime = 2 [features.field_presence = LEGACY_REQUIRED]; + // Hash algorithm of `digest`, for example "sha256". + string digest_algorithm = 3 [features.field_presence = LEGACY_REQUIRED]; + // Content digest over the whole artifact, as recorded on the log. Checking a + // range against this one requires reading every byte, which is what + // `chunk_size_bytes` exists to avoid. + bytes digest = 4 [features.field_presence = LEGACY_REQUIRED]; + // Chunk size of this artifact's manifest, when it has one. Unset means the + // artifact was stored without chunk hashing, so no range of it can be + // checked, and a caller that needs a checkable read should learn that here + // rather than by having a range read refused. + uint64 chunk_size_bytes = 5; +} diff --git a/proto/trogonai/session/sessions/diff/v1alpha1/structured_diff.proto b/proto/trogonai/session/sessions/diff/v1alpha1/structured_diff.proto new file mode 100644 index 0000000000..f1486453ba --- /dev/null +++ b/proto/trogonai/session/sessions/diff/v1alpha1/structured_diff.proto @@ -0,0 +1,85 @@ +edition = "2024"; + +package trogonai.session.sessions.diff.v1alpha1; + +// Structured diff artifact content for a recorded file change. +// +// This is artifact payload, not an event. It sits behind +// `DiffSummary.rendered`, which is a claim-check like any other, and a reader +// finds it there by the media type on `ArtifactRef.mime`. The alternative was +// putting hunks on FileChanged, which would put a presentation shape into a log +// that is never truncated (ADR#0035 facet 7): every review UI decision about how +// much context to show would become permanent history. +// +// It is defined in its own subtree and does not import the write-side types +// (ADR#0035 facet 3). A diff format changes for rendering reasons, on a review +// tool's schedule, and nothing about the session domain should have to move when +// it does. +// +// The counts on DiffSummary stay authoritative and are never recomputed from +// this. `DiffSummary.truncated` exists precisely because the artifact may omit +// hunks while the inline counts remain exact, so a reader that recounts from the +// hunks here will get a smaller number and will be wrong. + +// StructuredDiff is a parsed diff for one file change. +message StructuredDiff { + // Version of this structure's semantics, incremented when the meaning of an + // existing field changes rather than when fields are added. + // + // It is here and not only in the media type because an artifact outlives the + // reference that found it. A stored diff read years later through a generic + // artifact path has to be able to say what it is without the mime string that + // was attached to the claim-check. + uint32 format_version = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated DiffHunk hunks = 2; + // True when hunks were omitted. Mirrors DiffSummary.truncated so the artifact + // is self-describing: a consumer holding only these bytes must be able to tell + // a complete diff from a partial one without the summary that pointed at it. + bool truncated = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// DiffHunk is one contiguous region of change with its surrounding context. +message DiffHunk { + // First line of this hunk in the before-content, 1-based. Zero when the + // before-content does not exist, which is the create case. + uint32 old_start = 1 [features.field_presence = LEGACY_REQUIRED]; + // First line of this hunk in the after-content, 1-based. Zero when the + // after-content does not exist, which is the delete case. + uint32 new_start = 2 [features.field_presence = LEGACY_REQUIRED]; + // Section heading a renderer can show above the hunk, such as the enclosing + // function. Empty when none was determined. + string heading = 3; + repeated DiffLine lines = 4; +} + +// DiffLine is one line of a hunk. +message DiffLine { + LineKind kind = 1 [features.field_presence = LEGACY_REQUIRED]; + // Line content without its trailing newline and without a leading diff marker. + // The marker is `kind`, so a renderer never has to strip one character off the + // front of the text and hope it was punctuation rather than content. + // + // Empty for LINE_KIND_ELIDED, which stands for lines that are not here. + string text = 2; + // Line number in the before-content, 1-based. Unset for an added line, which + // has no position there. Absent rather than zero, so "this line did not exist + // before" cannot be read as "line zero". + uint32 old_line = 3; + // Line number in the after-content, 1-based. Unset for a removed line. + uint32 new_line = 4; + // How many lines LINE_KIND_ELIDED stands in for. Zero for every other kind. + uint32 elided_count = 5; +} + +// LineKind is what a line represents in the change. +enum LineKind { + LINE_KIND_UNSPECIFIED = 0; + // Unchanged, present for context. + LINE_KIND_CONTEXT = 1; + LINE_KIND_ADDED = 2; + LINE_KIND_REMOVED = 3; + // A run of lines omitted from this artifact. It carries a count instead of + // text, so a renderer can show that content is missing rather than joining two + // distant regions into what looks like adjacent code. + LINE_KIND_ELIDED = 4; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/diagnose_session.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/diagnose_session.proto new file mode 100644 index 0000000000..d9711f34ec --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/diagnose_session.proto @@ -0,0 +1,112 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/doctor/v1alpha1/finding.proto"; + +// DiagnoseSessionRequest inspects one session and reports what disagrees. +// +// This operation mutates nothing. It is not a mode of a repair operation and it +// has no flag that would make it one, because a report-only default that lives +// in a field is one typo away from not being the default. +message DiagnoseSessionRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Checks to run. Empty runs the default set, which excludes the checks whose + // cost scales with artifact storage rather than with the stream. + repeated CheckKind checks = 2; + InspectionBudget budget = 3; +} + +// InspectionBudget bounds the work a diagnosis may do. +// +// Inspection is unbounded by nature: verifying every artifact digest on a long +// session means reading every artifact. Without a budget the doctor becomes a +// load generator that operators learn not to run, and a diagnostic nobody dares +// use is worth nothing. +// +// Unset fields mean the server's default, not unlimited. +message InspectionBudget { + uint64 max_events_scanned = 1; + uint64 max_artifacts_verified = 2; + google.protobuf.Duration max_duration = 3; +} + +// CheckKind is one family of inspection. Checks are the unit a budget is spent +// on and the unit completeness is reported against. +enum CheckKind { + CHECK_KIND_UNSPECIFIED = 0; + // Stream presence and creation-batch completeness. + CHECK_KIND_STREAM_INTEGRITY = 1; + // Decode every event in range and report the ones that fail. + CHECK_KIND_EVENT_DECODE = 2; + // Fold the stream and confirm it produces a state. + CHECK_KIND_AGGREGATE_REPLAY = 3; + // Compare snapshots against a replay of the events they claim to cover. + CHECK_KIND_SNAPSHOT = 4; + // Projection lag, validity, and checkpoint agreement with the view. + CHECK_KIND_PROJECTION = 5; + // Read artifact content and recompute digests. Not in the default set: its + // cost is bounded by storage, not by the stream. + CHECK_KIND_ARTIFACT_DIGEST = 6; + // Reserved operations with indeterminate or overdue outcomes. + CHECK_KIND_OPERATION_LEDGER = 7; + // Delegation, detach, and cascade sequences that never terminated, and tool + // calls stranded in flight. + CHECK_KIND_UNRECONCILED_WORK = 8; + // Recovery checkpoints and their attestations. + CHECK_KIND_CHECKPOINT_ATTESTATION = 9; + // Claims and uploads with no durable owner. Not in the default set: deciding + // an orphan requires tracing ownership and projector watermarks, which is + // expensive and must never be approximated by a reference search. + CHECK_KIND_ORPHAN = 10; + // Retention and cold-tier watermarks against what is actually retained. + CHECK_KIND_RETENTION = 11; +} + +// DiagnoseSessionResponse is what the inspection found and, as importantly, +// what it did not look at. +// +// An empty `findings` list means the session is healthy only when every entry +// in `checks` reports CHECK_STATUS_COMPLETED. A doctor that ran out of budget +// halfway produces the same empty list as a clean session, and an operator +// reading only `findings` cannot tell those apart. Which checks ran is +// therefore part of the answer, not metadata about it. +message DiagnoseSessionResponse { + // Identifies this diagnosis. A repair must name it, so every mutation is + // traceable to the report that justified it. + string diagnosis_id = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated Finding findings = 2; + // One entry per check the server considered, including checks it skipped. + repeated CheckOutcome checks = 3; + google.protobuf.Timestamp observed_at = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// CheckOutcome is whether a check actually ran. +message CheckOutcome { + CheckKind check = 1 [features.field_presence = LEGACY_REQUIRED]; + CheckStatus status = 2 [features.field_presence = LEGACY_REQUIRED]; + uint32 findings_produced = 3 [features.field_presence = LEGACY_REQUIRED]; + // How far the check got before stopping, in whatever unit it consumes. Only + // meaningful with BUDGET_EXHAUSTED, where it tells an operator how much + // larger a budget would need to be. + uint64 progress = 4; + // Why a check was skipped or failed. Human-readable, never parsed. + string reason = 5; +} + +// CheckStatus is how a check ended. +enum CheckStatus { + CHECK_STATUS_UNSPECIFIED = 0; + // Ran to completion. Its findings, including none, are conclusive. + CHECK_STATUS_COMPLETED = 1; + // Ran and stopped early against the budget. Its findings are real; their + // absence proves nothing. + CHECK_STATUS_BUDGET_EXHAUSTED = 2; + // Not requested, or not applicable to this session. + CHECK_STATUS_SKIPPED = 3; + // The check itself failed. Reported rather than swallowed: a diagnostic that + // hides its own failures is worse than no diagnostic, because it is trusted. + CHECK_STATUS_FAILED = 4; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/doctor_error.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/doctor_error.proto new file mode 100644 index 0000000000..3dc31d90c2 --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/doctor_error.proto @@ -0,0 +1,44 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +// DoctorError is the typed failure payload for the doctor surface. +// +// Defined here rather than shared with the query contract's QueryError. The +// doctor is an operator surface with its own audience and its own release +// cadence, and pinning its failure vocabulary to a client-facing contract would +// mean every new operator diagnostic is a client-visible change. That is the +// same reasoning the query contract applies to projection value types, one +// subtree further out. +message DoctorError { + DoctorErrorCode code = 1 [features.field_presence = LEGACY_REQUIRED]; + // Human-readable, non-contractual. Never parse it. + string message = 2 [features.field_presence = LEGACY_REQUIRED]; + // Dotted path into the request for INVALID_ARGUMENT. + string field_path = 3; +} + +// DoctorErrorCode is why a diagnosis or repair could not be served. +enum DoctorErrorCode { + DOCTOR_ERROR_CODE_UNSPECIFIED = 0; + DOCTOR_ERROR_CODE_SESSION_NOT_FOUND = 1; + DOCTOR_ERROR_CODE_INVALID_ARGUMENT = 2; + // The repair names a diagnosis this server does not have. Repairs are bound + // to a report, so an unknown one is refused rather than treated as an + // unprovenanced repair. + DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND = 3; + // The diagnosis is known and too old to authorize a mutation. A report ages + // into a description of a session that no longer exists, and re-verification + // catches most of that but should not be the only thing standing between a + // stale report and a destructive action. + DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED = 4; + // The repair names findings from a different session than it targets. + DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH = 5; + // The caller may not inspect or repair this session. Diagnosis and repair are + // authorized separately: read access to a report does not carry the right to + // act on it. + DOCTOR_ERROR_CODE_PERMISSION_DENIED = 6; + // The requested inspection is too expensive to admit even with a budget. + DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED = 7; + DOCTOR_ERROR_CODE_INTERNAL = 8; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/finding.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/finding.proto new file mode 100644 index 0000000000..4069eb3381 --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/finding.proto @@ -0,0 +1,244 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/doctor/v1alpha1/orphan.proto"; +import "trogonai/session/sessions/doctor/v1alpha1/repair_action.proto"; + +// Finding is one inconsistency the doctor observed. +// +// A finding is an observation, never an instruction. It says what disagrees +// with what, and it names the repairs that could address it, but producing one +// mutates nothing. That separation is the whole design: diagnosis and repair are +// different operations with different messages, so a caller cannot reach a +// mutation by filling in one more field on a read. +message Finding { + // Stable identity for this problem: a digest over `kind` and `subject`. + // + // Deliberately not a digest over the observed values. A projection that falls + // further behind between diagnosis and repair is still the same finding, and + // an id that changed with every observed byte would make repairs impossible on + // a busy session. Staleness is caught by re-verifying the finding at repair + // time, not by comparing ids. + string finding_id = 1 [features.field_presence = LEGACY_REQUIRED]; + FindingKind kind = 2 [features.field_presence = LEGACY_REQUIRED]; + FindingSeverity severity = 3 [features.field_presence = LEGACY_REQUIRED]; + SubjectRef subject = 4 [features.field_presence = LEGACY_REQUIRED]; + // Human-readable, non-contractual, safe to log. Never parse it. + string summary = 5 [features.field_presence = LEGACY_REQUIRED]; + // Repairs that could address this finding, and the only actions a + // RepairSessionRequest may name for it. An empty list means nothing the + // doctor can do will help, which is the normal case for a CORRUPT finding. + repeated RepairAction available_repairs = 6; + google.protobuf.Timestamp observed_at = 7 [features.field_presence = LEGACY_REQUIRED]; + // Machine-readable specifics. `kind` sits outside this union on purpose: an + // unset oneof and a variant added after the reader was built are + // indistinguishable, so the kind is what stays readable either way. + oneof detail { + EventDecodeDetail event_decode = 8; + ProjectionCheckpointDetail projection_checkpoint = 9; + ArtifactDigestDetail artifact_digest = 10; + OperationLedgerDetail operation_ledger = 11; + UnreconciledWorkDetail unreconciled_work = 12; + OrphanDetail orphan = 13; + } +} + +// FindingSeverity is what an operator has to decide, not a feelings scale. +// +// The question a severity answers here is whether rebuilding derived state can +// fix this. That is the only distinction that changes what an operator does +// next, so it is the one the enum encodes. +enum FindingSeverity { + FINDING_SEVERITY_UNSPECIFIED = 0; + // Worth knowing, nothing is wrong. A projection a few events behind a busy + // stream is the normal state of a projection, not a defect. + FINDING_SEVERITY_INFO = 1; + // Derived state disagrees with the stream. Reads may be wrong, the stream is + // intact, and rebuilding from it is expected to resolve the finding. + FINDING_SEVERITY_DEGRADED = 2; + // The stream itself cannot be fully interpreted. No amount of rebuilding + // helps, because the thing that would be rebuilt from is the problem. These + // findings usually carry no available repairs, and that is the honest answer + // rather than a gap. + FINDING_SEVERITY_CORRUPT = 3; +} + +// FindingKind is what was observed. +// +// Open by protobuf's rules and treated as open here: a reader that meets an +// unrecognized kind has reached a newer doctor and must surface it as an +// unknown finding rather than drop it. A dropped finding reads as health. +enum FindingKind { + FINDING_KIND_UNSPECIFIED = 0; + // The session's stream does not exist. + FINDING_KIND_STREAM_MISSING = 1; + // A creation batch landed partially. The session exists but its opening + // invariants were never completed. + FINDING_KIND_CREATION_BATCH_INCOMPLETE = 2; + // An event at a known ordinal could not be decoded. + FINDING_KIND_EVENT_DECODE_FAILED = 3; + // An event carries a type this build does not know. Distinct from a decode + // failure: the bytes may be fine and this reader is simply older. + FINDING_KIND_UNSUPPORTED_EVENT_TYPE = 4; + // Folding the stream did not produce a state. Usually downstream of a decode + // failure, reported separately because a replay can also fail on events that + // each decode cleanly. + FINDING_KIND_AGGREGATE_REPLAY_FAILED = 5; + // A snapshot does not match a replay of the events it claims to cover. + FINDING_KIND_SNAPSHOT_INVALID = 6; + // A snapshot is valid but far enough behind to have stopped being useful. + FINDING_KIND_SNAPSHOT_BEHIND = 7; + // A projection is behind its source beyond the configured tolerance. + FINDING_KIND_PROJECTION_BEHIND = 8; + // A projection failed its own validity checks. + FINDING_KIND_PROJECTION_INVALID = 9; + // A projection checkpoint claims a position the source stream does not have. + // Nothing legitimate produces this; it means the checkpoint and the stream + // come from different histories. + FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE = 10; + // A projection checkpoint claims to have applied an event that is absent from + // the materialized view. The checkpoint and the view disagree about the same + // projection. + FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT = 11; + // An artifact referenced by the session is not present in storage. + FINDING_KIND_ARTIFACT_MISSING = 12; + // An artifact is present and its content no longer matches its recorded + // digest. + FINDING_KIND_ARTIFACT_DIGEST_MISMATCH = 13; + // An artifact claim or multipart upload references nothing durable. + FINDING_KIND_ORPHANED_ARTIFACT_CLAIM = 14; + // A recovery checkpoint or its attestation failed verification. + FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID = 15; + // A delegation, detach, or cascade sequence started and never reached a + // terminal step. + FINDING_KIND_SAGA_INCOMPLETE = 16; + // A reserved operation recorded an indeterminate outcome. Non-terminal by + // design, so this is a finding only once it is also overdue. + FINDING_KIND_OPERATION_OUTCOME_UNKNOWN = 17; + // A reserved operation has recorded no outcome past its expected settlement + // window. + FINDING_KIND_OPERATION_OUTCOME_OVERDUE = 18; + // A tool call reached a started state and never recorded a terminal outcome, + // in a session that is already terminal. This is the crash-recovery case the + // aggregate's fold exists to expose. + FINDING_KIND_TOOL_CALL_UNRECONCILED = 19; + // A retention or cold-tier watermark disagrees with what is actually + // retained. + FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT = 20; + // Derived state left behind by a computation that no longer runs: an + // abandoned projection generation, staging from a finished migration, a + // reconciliation lease whose holder never came back. + // + // Separate from ORPHANED_ARTIFACT_CLAIM because releasing it destroys + // something the stream can regenerate, and that difference is the whole basis + // on which an operator decides how carefully to look first. + FINDING_KIND_ORPHANED_DERIVED_STATE = 21; +} + +// SubjectRef says what a finding is about. +// +// `kind` is what gives `entity_id` meaning, and the pair travels together for +// that reason: an id with no idea what it identifies is not a reference. +message SubjectRef { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + SubjectKind kind = 2 [features.field_presence = LEGACY_REQUIRED]; + // Interpreted according to `kind`: an artifact id, an operation id, a tool + // execution id, a projection name. Unset when `kind` is STREAM, which needs + // no further identity than the session. + string entity_id = 3; + // The SessionOrdinal the finding is anchored at. Unset when the finding is + // not ordinal-scoped, which is not the same as ordinal zero. + uint64 ordinal = 4; +} + +// SubjectKind is which part of a session a finding concerns. +enum SubjectKind { + SUBJECT_KIND_UNSPECIFIED = 0; + SUBJECT_KIND_STREAM = 1; + SUBJECT_KIND_EVENT = 2; + SUBJECT_KIND_SNAPSHOT = 3; + SUBJECT_KIND_PROJECTION = 4; + SUBJECT_KIND_ARTIFACT = 5; + SUBJECT_KIND_OPERATION = 6; + SUBJECT_KIND_TOOL_CALL = 7; + SUBJECT_KIND_DELEGATION = 8; + SUBJECT_KIND_CHECKPOINT = 9; +} + +// EventDecodeDetail is enough to find the offending event without re-running +// the scan. +message EventDecodeDetail { + uint64 ordinal = 1 [features.field_presence = LEGACY_REQUIRED]; + string type_url = 2 [features.field_presence = LEGACY_REQUIRED]; + // Decoder error text. Diagnostic only, never parsed. + string decoder_error = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// ProjectionCheckpointDetail carries the three positions whose disagreement is +// the finding, because a checkpoint inconsistency is unreadable without all +// three. +message ProjectionCheckpointDetail { + string projection_name = 1 [features.field_presence = LEGACY_REQUIRED]; + string projection_generation = 2 [features.field_presence = LEGACY_REQUIRED]; + // What the checkpoint claims was applied. + uint64 checkpoint_watermark = 3 [features.field_presence = LEGACY_REQUIRED]; + // What the materialized view actually reflects. Below the checkpoint means + // the checkpoint is lying about work the view never received. + uint64 view_applied_through = 4 [features.field_presence = LEGACY_REQUIRED]; + // The source head. Below the checkpoint means the checkpoint refers to + // history this stream does not have. + uint64 source_high_watermark = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// ArtifactDigestDetail distinguishes the three ways an artifact fails +// verification, which the digests alone cannot express. +message ArtifactDigestDetail { + string artifact_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ArtifactDigestObservation observation = 2 [features.field_presence = LEGACY_REQUIRED]; + // The digest recorded when the artifact was stored. + string expected_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + // The digest computed during this check. Unset when the content could not be + // read at all, which is why this is not simply compared to the expected one. + string observed_digest = 4; +} + +// ArtifactDigestObservation is what the verification attempt found. +enum ArtifactDigestObservation { + ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED = 0; + // Content read, digest computed, digests differ. + ARTIFACT_DIGEST_OBSERVATION_MISMATCH = 1; + // Content is not present in storage. + ARTIFACT_DIGEST_OBSERVATION_ABSENT = 2; + // Content is present and could not be read. Distinct from absent: an + // unreadable artifact may be a permissions or transport problem rather than + // data loss, and treating it as loss invites a destructive repair. + ARTIFACT_DIGEST_OBSERVATION_UNREADABLE = 3; +} + +// OperationLedgerDetail describes a side effect that never settled. +message OperationLedgerDetail { + string operation_id = 1 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp reserved_at = 2 [features.field_presence = LEGACY_REQUIRED]; + // How far past its expected settlement window the operation is. Unset when no + // window applies. + google.protobuf.Duration overdue_by = 3; + // True when an indeterminate outcome was recorded, meaning the side effect + // may or may not have run. An operator must not assume either. + bool outcome_indeterminate = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// UnreconciledWorkDetail describes work the fold shows as started and never +// finished. +message UnreconciledWorkDetail { + // Tool execution id, delegation id, or saga id, per the subject kind. + string entity_id = 1 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp started_at = 2 [features.field_presence = LEGACY_REQUIRED]; + // True when the session has already reached a terminal marker. A session can + // be terminally successful and still have work stranded in flight, and that + // combination is exactly what a reader treating terminal as complete will + // miss. + bool session_terminal = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/orphan.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/orphan.proto new file mode 100644 index 0000000000..272e91a446 --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/orphan.proto @@ -0,0 +1,173 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +// Orphan reporting for the doctor. +// +// An orphan is a resource that was staged for a write that never landed. The +// canonical shape is an artifact upload that succeeded followed by an append +// that failed: the bytes are durable, nothing references them, and nothing ever +// will. Left alone they accumulate; deleted carelessly they take live content +// with them. +// +// Every message here exists to make the second failure hard. The point is not +// to find candidates, which is easy, but to state what was actually traced and +// what is still holding a release back, so that deleting something is a +// decision an operator makes against evidence rather than against a count. + +// OrphanClass is what kind of resource was left behind. +// +// They are enumerated separately rather than collapsed into "unreferenced +// thing" because they have different owners, different ways of being +// referenced, and different consequences for getting it wrong. Releasing an +// abandoned projection generation costs a rebuild. Releasing a claim check that +// was about to be referenced destroys the only copy of a command's output. +enum OrphanClass { + ORPHAN_CLASS_UNSPECIFIED = 0; + // A multipart upload with parts written and no completion. It holds storage, + // it has no digest yet, and no event can reference it because the object it + // would name does not exist. + ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD = 1; + // A completed object with a digest that no event in any stream references. + // + // The dangerous one. Content-addressed storage means the same bytes can be + // reachable through a stream nobody thought to scan, so this class is the + // reason ownership has to be traced rather than searched for. + ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK = 2; + // Materialized state belonging to a projection generation that is neither + // current nor being rebuilt. Disposable by construction: the stream can + // produce it again. + ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION = 3; + // Staging state from a migration that has since finished. It was never the + // source of truth, and it stops being a fallback once the migration is done. + ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING = 4; + // A reconciliation lease past its expiry whose holder never returned. + // + // Releasing this one is not a deletion, it is a handoff: the work the lease + // covered still needs settling, and reclaiming the lease is what lets someone + // else settle it. + ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE = 5; +} + +// OrphanDetail is the evidence behind an orphan finding. +message OrphanDetail { + OrphanClass orphan_class = 1 [features.field_presence = LEGACY_REQUIRED]; + // Upload id, artifact id, projection generation, migration id, or lease id, + // per `orphan_class`. + string resource_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // When the resource was created in its store, as the store recorded it. A + // wall-clock occurrence, not a position derived from append order (D10), + // because an orphan by definition never reached the log. + google.protobuf.Timestamp staged_at = 3 [features.field_presence = LEGACY_REQUIRED]; + // How long it has been sitting there, as of the finding's `observed_at`. + google.protobuf.Duration age = 4 [features.field_presence = LEGACY_REQUIRED]; + // What was actually checked before calling this unreferenced. + OwnershipTrace trace = 5 [features.field_presence = LEGACY_REQUIRED]; + // What still has to be true before it can be released. + ReleaseGate gate = 6 [features.field_presence = LEGACY_REQUIRED]; + // Storage this would return. Unset when the store cannot say, which is + // ordinary for an incomplete multipart upload and is not zero bytes. + uint64 reclaimable_bytes = 7; +} + +// OwnershipTrace is what the orphan check looked at, and how far it got. +// +// This message is the difference between a finding and a guess. "No reference +// found" is only meaningful alongside where the search ran and where it +// stopped, and a check that scanned four of a tenant's streams produces the +// same empty result as one that scanned all of them. +message OwnershipTrace { + TraceCompleteness completeness = 1 [features.field_presence = LEGACY_REQUIRED]; + // Streams the trace read to completion. + uint32 streams_scanned = 2 [features.field_presence = LEGACY_REQUIRED]; + // Streams in scope the trace could not read. Any non-zero value makes the + // result non-exhaustive no matter how many streams were scanned, because the + // reference could be in exactly one of them. + uint32 streams_unreadable = 3 [features.field_presence = LEGACY_REQUIRED]; + // Position the trace scanned through. + uint64 scanned_through_watermark = 4 [features.field_presence = LEGACY_REQUIRED]; + // Head at the time the trace ran. Above `scanned_through_watermark` means + // events were appended during the scan, and a reference could be in the gap. + uint64 source_high_watermark = 5 [features.field_presence = LEGACY_REQUIRED]; + // Position the slowest projector needed for this trace had applied through. + // + // A trace that consults derived state is only as complete as that state. A + // projector behind the scan makes the trace's answer a statement about + // history the projector has already seen, which is not the same as the + // history that exists. + uint64 projector_applied_through = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// TraceCompleteness is how much of the search space the trace actually covered. +enum TraceCompleteness { + // Unknown coverage. Treat as INCOMPLETE. + TRACE_COMPLETENESS_UNSPECIFIED = 0; + // Every stream in scope was read to the head observed at scan time, and + // every projector consulted was current with it. + TRACE_COMPLETENESS_EXHAUSTIVE = 1; + // Coverage was cut short by a budget: a time limit, a stream limit, a byte + // limit. Whatever was scanned is accurate, and the unscanned part is unknown. + TRACE_COMPLETENESS_BOUNDED = 2; + // Something in scope could not be read at all. Distinct from BOUNDED because + // a bounded trace can be finished by granting more budget, and this one + // cannot be finished until the fault is fixed. + TRACE_COMPLETENESS_INCOMPLETE = 3; +} + +// ReleaseGate is what stands between an orphan finding and deleting something. +// +// Nothing is released on age alone and nothing is released on absence of +// references alone. Both are necessary and neither is sufficient, which is why +// the outcome is a single value rather than a set of flags a caller could read +// selectively. +message ReleaseGate { + GateOutcome outcome = 1 [features.field_presence = LEGACY_REQUIRED]; + // How old a resource of this class must be before release is considered. + google.protobuf.Duration minimum_age = 2 [features.field_presence = LEGACY_REQUIRED]; + // How long an append can remain indeterminate before its outcome is settled + // one way or the other. + // + // This is the number that makes the whole gate correct. An append whose write + // state is unknown may still land, and if it lands it carries a reference to + // a resource that a cleanup pass has already decided nothing points at. So + // `minimum_age` has to exceed this window, and a resource inside it is held + // regardless of how thoroughly it was traced: the trace was accurate and the + // history was not finished happening. + google.protobuf.Duration indeterminacy_window = 3 [features.field_presence = LEGACY_REQUIRED]; + // Earliest time this could become releasable, if nothing changes. Unset when + // waiting will not help, which is the case for every outcome that depends on + // a fault being fixed rather than on time passing. + google.protobuf.Timestamp releasable_after = 4; +} + +// GateOutcome is whether this orphan may be released now, and if not, why not. +// +// The zero value holds and RELEASABLE is last, so a reader that does not +// recognize a variant keeps the resource. Getting this backwards would make an +// unknown enum value a deletion. +enum GateOutcome { + // Unknown outcome. Hold. + GATE_OUTCOME_UNSPECIFIED = 0; + // Younger than `minimum_age`. + GATE_OUTCOME_HELD_TOO_YOUNG = 1; + // Inside the indeterminacy window of an append that has not settled. The + // reference may still arrive. + GATE_OUTCOME_HELD_INDETERMINATE_APPEND = 2; + // The ownership trace did not cover the search space, so "unreferenced" has + // not actually been established. + GATE_OUTCOME_HELD_TRACE_INCOMPLETE = 3; + // A projector the trace depends on is behind the stream head. Held rather + // than reported as incomplete, because this one resolves on its own once the + // projector catches up. + GATE_OUTCOME_HELD_PROJECTOR_BEHIND = 4; + // Old enough, exhaustively traced, no unsettled append in range. A repair may + // release it. + // + // Still not an instruction. The doctor observes and never mutates; releasing + // is a RepairSession call naming this finding, and the gate is re-evaluated + // then, because everything it asserts can stop being true in the interval. + GATE_OUTCOME_RELEASABLE = 5; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/repair_action.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/repair_action.proto new file mode 100644 index 0000000000..9ca8deb916 --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/repair_action.proto @@ -0,0 +1,62 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +// RepairAction is something the doctor can do about a finding. +// +// Every value in this enum operates on derived state: a projection, a +// checkpoint, a snapshot, a claim. That is not a coincidence and it is not a +// starting point to be extended later. +// +// The event stream is the source of truth and it is append-only. A repair that +// edited, deleted, or reordered events would make the log depend on the tooling +// built to inspect it, and every guarantee that rests on replay determinism +// would rest instead on nobody having run the wrong repair. So no such action +// exists here, and adding one is a decision about the architecture rather than +// an addition to a list. +// +// The corollary catches the case operators most often expect to find here. +// Reconciling a tool call that never recorded an outcome is not a repair. It is +// CompleteToolCall or FailToolCall, an ordinary command through the ordinary +// decider, subject to the ordinary invariants. Routing it through the doctor +// would let an operator write history without passing the rules that make the +// history mean anything. +enum RepairAction { + REPAIR_ACTION_UNSPECIFIED = 0; + // Rebuild a projection from the stream under a new generation. The workhorse: + // it addresses most DEGRADED findings and it is safe because the input is + // authoritative and the output is disposable. + REPAIR_ACTION_REBUILD_PROJECTION = 1; + // Mark a projection generation unreadable so reads fail closed instead of + // serving state known to be wrong. Used when a rebuild is not immediately + // possible, and it makes the situation worse for readers on purpose: a + // refused read is recoverable, a believed wrong answer is not. + REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION = 2; + // Reset a projection checkpoint to the position the materialized view + // actually reflects, so the projector reprocesses the gap it skipped. + REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT = 3; + // Discard a snapshot so the aggregate is folded from events again. Always + // safe and never necessary for correctness, since a snapshot is a cache. + REPAIR_ACTION_DISCARD_SNAPSHOT = 4; + // Recompute an artifact's digest from storage. This is a re-observation, not + // a mutation, and it exists as an action because a digest finding is often a + // transient read failure rather than data loss. + REPAIR_ACTION_REVERIFY_ARTIFACT = 5; + // Release an artifact claim or multipart upload that references nothing + // durable. The only action here that destroys anything, which is why the + // finding it answers requires tracing durable ownership rather than a + // reference search. + REPAIR_ACTION_RELEASE_ORPHANED_CLAIM = 6; + // Discard derived state belonging to a computation that no longer runs: an + // abandoned projection generation, staging from a completed migration. + // + // Distinct from releasing a claim, which is the only other action that + // destroys anything, because this one destroys something reproducible. The + // gate on the finding still has to pass: the cheap thing to get wrong here is + // discarding the generation a rebuild is currently writing into. + REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE = 7; + // Reclaim an expired reconciliation lease so another worker can settle the + // operation it covered. A handoff rather than a deletion: the work still + // exists and still needs an outcome. + REPAIR_ACTION_RECLAIM_EXPIRED_LEASE = 8; +} diff --git a/proto/trogonai/session/sessions/doctor/v1alpha1/repair_session.proto b/proto/trogonai/session/sessions/doctor/v1alpha1/repair_session.proto new file mode 100644 index 0000000000..9845171565 --- /dev/null +++ b/proto/trogonai/session/sessions/doctor/v1alpha1/repair_session.proto @@ -0,0 +1,108 @@ +edition = "2024"; + +package trogonai.session.sessions.doctor.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/doctor/v1alpha1/repair_action.proto"; + +// RepairSessionRequest applies typed repairs to findings from a specific +// diagnosis. +// +// Three properties make this safe, and each of them closes a failure that +// operator tooling reaches for eventually. +// +// It is targeted. There is no "repair everything" shape. A caller names exact +// findings and the exact action for each, because a bulk repair is a repair +// whose blast radius nobody reviewed. +// +// It is provenanced. `diagnosis_id` binds every mutation to the report that +// justified it, so an audit can answer what the operator was looking at. +// +// It re-verifies. The server re-runs each finding's check before acting on it. +// The interval between running a doctor and running a repair is where state +// changes, and a repair that trusts a report from ten minutes ago will happily +// discard a projection that already rebuilt itself. +message RepairSessionRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The diagnosis whose findings are being acted on. Findings from a different + // diagnosis are refused rather than looked up, so a repair cannot be + // assembled from ids an operator collected by hand. + string diagnosis_id = 2 [features.field_presence = LEGACY_REQUIRED]; + RepairMode mode = 3 [features.field_presence = LEGACY_REQUIRED]; + repeated RepairTarget targets = 4; + // Why the operator is doing this, for the audit record. Required, and + // required to be non-empty: a repair with no stated reason is the one that + // will need explaining later. + string operator_reason = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// RepairMode is whether this call is allowed to mutate anything. +// +// The numbering is load-bearing. Zero is DRY_RUN, so a caller that forgets the +// field, decodes an older message, or builds a request programmatically and +// misses a branch gets a preview rather than a mutation. Every other ordering +// of these values makes the default destructive, and a default that destroys +// is a defect no amount of documentation fixes. +enum RepairMode { + // Treated as DRY_RUN. Unset is a preview, never an apply. + REPAIR_MODE_UNSPECIFIED = 0; + // Re-verify every target and report what would happen. Mutates nothing. + REPAIR_MODE_DRY_RUN = 1; + // Re-verify every target and apply the ones that still hold. + REPAIR_MODE_APPLY = 2; +} + +// RepairTarget is one finding and the action to take on it. +message RepairTarget { + string finding_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Must be one of the finding's `available_repairs`. An action the doctor did + // not offer for this finding is refused, so the set of legal repairs is + // decided by the code that understands the finding rather than by the caller. + RepairAction action = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// RepairSessionResponse is what happened, or what would have. +message RepairSessionResponse { + // Echoes the mode that ran. A dry run and an apply must never be + // distinguishable only by what the caller believes it sent. + RepairMode mode = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated RepairResult results = 2; + google.protobuf.Timestamp observed_at = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// RepairResult is the outcome for one target. +message RepairResult { + string finding_id = 1 [features.field_presence = LEGACY_REQUIRED]; + RepairAction action = 2 [features.field_presence = LEGACY_REQUIRED]; + RepairResultStatus status = 3 [features.field_presence = LEGACY_REQUIRED]; + // What the action touched, or would touch: projection generations, snapshot + // ids, claim ids. The substance of a dry run, and the audit trail of an + // apply. + repeated string affected = 4; + // Human-readable detail. Never parsed. + string detail = 5; +} + +// RepairResultStatus is per-target, because a repair call is not atomic and +// pretending otherwise would hide which half of it landed. +enum RepairResultStatus { + REPAIR_RESULT_STATUS_UNSPECIFIED = 0; + // Dry run: the finding still holds and the action would be taken. + REPAIR_RESULT_STATUS_WOULD_APPLY = 1; + // Apply: the action was taken. + REPAIR_RESULT_STATUS_APPLIED = 2; + // Re-verification found the finding no longer holds. Not an error: the + // problem resolved itself between diagnosis and repair, and doing nothing is + // the correct outcome. + REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE = 3; + // The action is not among the finding's available repairs. + REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE = 4; + // The finding still holds and the server declined to act, because applying + // the action in the current state could destroy something recoverable. An + // unreadable artifact is the standard case: it is not yet known to be lost, + // so nothing that treats it as lost may run. + REPAIR_RESULT_STATUS_REFUSED_UNSAFE = 5; + // The action was attempted and failed. Distinct from refused: something may + // have partially changed, and `affected` says what. + REPAIR_RESULT_STATUS_FAILED = 6; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/maintenance_error.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/maintenance_error.proto new file mode 100644 index 0000000000..88548eb6cd --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/maintenance_error.proto @@ -0,0 +1,46 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +// MaintenanceError is the typed failure payload for the migration and salvage +// surface. +// +// Kept separate from QueryError and DoctorError on the same reasoning each of +// those applies: these are operator operations that rewrite or duplicate +// durable state, and their failure vocabulary should be free to grow without +// that growth being a client-visible or diagnostic-visible change. +// +// An operation that ran and could not be classified is not an error. It is a +// successful call reporting MAINTENANCE_STATE_INDETERMINATE, because it has a +// durable record and a defined next step, and turning it into an error would +// discard both. +message MaintenanceError { + MaintenanceErrorCode code = 1 [features.field_presence = LEGACY_REQUIRED]; + // Human-readable, non-contractual. Never parse it. + string message = 2 [features.field_presence = LEGACY_REQUIRED]; + // Dotted path into the request for INVALID_ARGUMENT. + string field_path = 3; +} + +// MaintenanceErrorCode is why an operation could not be attempted. +enum MaintenanceErrorCode { + MAINTENANCE_ERROR_CODE_UNSPECIFIED = 0; + MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND = 1; + MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT = 2; + // Reconciliation was asked about an identity with no recorded intent. Distinct + // from an indeterminate outcome: there is no operation to reconcile, so there + // is nothing to report a state for. + MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND = 3; + // The request's parameters do not reproduce the identity it names. Refused + // rather than treated as a new operation, because the caller believes it is + // retrying something it is not. + MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH = 4; + // Another maintenance operation holds this session. Two concurrent migrations + // of one session both write a target, and only one can be right. + MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS = 5; + // Planning and committing are authorized separately: the right to see what a + // migration would do does not carry the right to run it. + MAINTENANCE_ERROR_CODE_PERMISSION_DENIED = 6; + MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED = 7; + MAINTENANCE_ERROR_CODE_INTERNAL = 8; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/migrate_session.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/migrate_session.proto new file mode 100644 index 0000000000..71ce30b86f --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/migrate_session.proto @@ -0,0 +1,60 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/migration.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto"; + +// MigrateSession rewrites one session's stored events under a newer storage +// schema, keeping the session's identity and its ordinals. +// +// Ordering of effects is fixed and not an implementation detail: record the +// intent, stage the target, commit, validate. A process that dies at any point +// leaves state that ReconcileMigration can classify, because the intent was +// written before anything else was. +message MigrateSessionRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + uint32 target_schema_version = 2 [features.field_presence = LEGACY_REQUIRED]; + string implementation_version = 3 [features.field_presence = LEGACY_REQUIRED]; + string actor = 4 [features.field_presence = LEGACY_REQUIRED]; + string reason = 5 [features.field_presence = LEGACY_REQUIRED]; + // Unset is PLAN_ONLY. The zero value is the one that writes nothing, so a + // caller that forgets the field gets a plan instead of a rewrite. + MigrationMode mode = 6; + // The source boundary the caller already observed. A fleet orchestrator that + // read the source sets this, and the migration refuses if the source has + // moved since. Unset means the migration observes and pins the boundary + // itself, which is correct for a single session and racy for a fleet run that + // decided what to migrate minutes ago. + StreamBoundary expected_source = 7; + MigrationLimits limits = 8; +} + +// MigrationMode is whether this call may write. +enum MigrationMode { + MIGRATION_MODE_UNSPECIFIED = 0; + // Validate admissibility, compute the intent, write nothing. + MIGRATION_MODE_PLAN_ONLY = 1; + MIGRATION_MODE_COMMIT = 2; +} + +// MigrationLimits bounds one call. A migration reads and rewrites an entire +// stream, so an unbounded one on a large session is an outage. +message MigrationLimits { + uint64 max_source_events = 1; + uint64 max_source_bytes = 2; + google.protobuf.Duration max_duration = 3; +} + +message MigrateSessionResponse { + MigrationResult result = 1 [features.field_presence = LEGACY_REQUIRED]; + // Always present, including on refusal: the record is what a later + // reconciliation is run against, so a caller that cannot store it cannot + // reconcile. + MigrationRecord record = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set only for MIGRATION_RESULT_NOT_ADMISSIBLE. + AdmissibilityDetail not_admissible = 3; + google.protobuf.Timestamp observed_at = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/migration.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/migration.proto new file mode 100644 index 0000000000..bea4e3cdaa --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/migration.proto @@ -0,0 +1,143 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/outcome.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto"; + +// The durable record of a Session migration. +// +// A migration rewrites one session's stored events under a newer storage schema +// and keeps the session's identity. Two rules make that safe, and both are +// admissibility requirements rather than best effort: +// +// 1. Ordinals are preserved exactly. The target has the same event count as the +// source, one transformed payload per source position. Inserting or removing +// an event would renumber every following SessionOrdinal, and ordinals are +// referenced from outside this stream: fork context boundaries on child +// sessions, checkpoint evidence, consistency tokens, and page cursors would +// all silently come to mean something else. +// 2. The transformation is byte-deterministic. Given the same source bytes and +// the same implementation_version, it produces the same target bytes. +// +// The second rule is what makes a lost commit acknowledgment recoverable: the +// expected target digest can be written down before the commit, so a later look +// at the target answers "did my write land" instead of "did some write land." +// A transformation that cannot reproduce its own output is not a migration. It +// is a salvage, and it must mint a new identity. + +// MigrationIdentity is the retry identity of a migration. +// +// Two attempts sharing this tuple are the same migration and the second is +// idempotent. Two attempts differing anywhere in it are different migrations, +// and treating the second as a retry of the first is how a session gets +// migrated twice. +message MigrationIdentity { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Digest of the source cut. Part of identity because a migration of different + // source content is a different migration even under the same version pair. + ContentDigest source_digest = 2 [features.field_presence = LEGACY_REQUIRED]; + // Pins the transformation, including its encoder. Byte-determinism is scoped + // to this value: a new encoder is a new implementation_version, because the + // output bytes are part of what it promises. + string implementation_version = 3 [features.field_presence = LEGACY_REQUIRED]; + uint32 source_schema_version = 4 [features.field_presence = LEGACY_REQUIRED]; + uint32 target_schema_version = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// MigrationIntent is written durably before any target byte is written. +// +// This is the load-bearing record of the whole workflow. Reconciliation is a +// comparison, and a comparison needs something recorded on the near side of the +// crash. Without an intent, a process that dies mid-commit leaves a target that +// nobody can attribute and nobody can safely replace. +message MigrationIntent { + MigrationIdentity identity = 1 [features.field_presence = LEGACY_REQUIRED]; + StreamBoundary source = 2 [features.field_presence = LEGACY_REQUIRED]; + // The boundary the target will have if the commit lands, computed before the + // commit is attempted. `expected_target.ordinal` always equals + // `source.ordinal`; a plan where they differ is not admissible. + StreamBoundary expected_target = 3 [features.field_presence = LEGACY_REQUIRED]; + string actor = 4 [features.field_presence = LEGACY_REQUIRED]; + // Why this migration was run. A migration is a rewrite of durable history, + // and an unattributed rewrite is not auditable. + string reason = 5 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp planned_at = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// MigrationRecord is the intent plus everything learned since. +message MigrationRecord { + MigrationIntent intent = 1 [features.field_presence = LEGACY_REQUIRED]; + MaintenanceState state = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set only for MAINTENANCE_STATE_INDETERMINATE. + IndeterminateDetail indeterminate = 3; + // The target as actually observed. Unset before any commit was attempted, and + // unset after a reconciliation that found no target. + StreamBoundary observed_target = 4; + // Attempts made under this identity. A rising count against an unchanged + // state is the signal that a retry loop is not converging. + uint32 attempt_count = 5 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp updated_at = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// MigrationResult is the disposition of one MigrateSession call. +enum MigrationResult { + MIGRATION_RESULT_UNSPECIFIED = 0; + // This call performed the migration. + MIGRATION_RESULT_MIGRATED = 1; + // The session was already at the target schema version and no work was + // needed. Distinct from MIGRATED so a fleet run can report how much it + // actually rewrote. + MIGRATION_RESULT_ALREADY_CURRENT = 2; + // A prior attempt under this identity already committed. Reported instead of + // MIGRATED so a retry never claims work it did not do, which is exactly the + // claim the user's lost acknowledgment would otherwise produce. + MIGRATION_RESULT_ALREADY_MIGRATED = 3; + // The plan was rejected before any write. Carries an AdmissibilityDetail. + MIGRATION_RESULT_NOT_ADMISSIBLE = 4; + // The migration did not commit, and that is known. + MIGRATION_RESULT_FAILED = 5; + // The outcome could not be classified. Carries an IndeterminateDetail on the + // record. + MIGRATION_RESULT_INDETERMINATE = 6; + // PLAN_ONLY: the plan is admissible and nothing was written. + MIGRATION_RESULT_WOULD_MIGRATE = 7; +} + +// AdmissibilityDetail is why a migration was refused before writing anything. +// +// Every reason here is a reason to reach for salvage instead. A migration that +// bends any of these rules keeps the session's identity while changing what its +// ordinals mean, and nothing downstream would notice. +message AdmissibilityDetail { + AdmissibilityReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; + // The source position that triggered the refusal, where one did. + uint64 ordinal = 2; + // The source event type that triggered it, where one did. + string type_url = 3; + string detail = 4; +} + +// AdmissibilityReason is the specific rule a plan violated. +enum AdmissibilityReason { + ADMISSIBILITY_REASON_UNSPECIFIED = 0; + // An event type in the source has no representation in the target schema. + // Dropping it would renumber ordinals, so the migration refuses. + ADMISSIBILITY_REASON_TYPE_REMOVED = 1; + // An event decoded and carries a value the target schema cannot express. + ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE = 2; + // Source bytes did not decode. A migration transforms events it understands; + // recovering ones it does not is salvage. + ADMISSIBILITY_REASON_SOURCE_UNDECODABLE = 3; + // The transformation could not commit to a reproducible output, so a retry + // could not be distinguished from a divergence. + ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC = 4; + // The source is larger than the limits allowed for a single operation. + ADMISSIBILITY_REASON_SIZE_LIMIT = 5; + // The source is still being written to. A migration of a moving stream is a + // migration of an arbitrary prefix. + ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED = 6; + // Another maintenance operation holds this session. + ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS = 7; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/outcome.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/outcome.proto new file mode 100644 index 0000000000..996e473866 --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/outcome.proto @@ -0,0 +1,80 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto"; + +// MaintenanceState is the lifecycle shared by migration and salvage. +// +// The two workflows differ in almost everything else and share this because +// they share the same crash-exposed middle: durable work that is staged but not +// yet authoritative, and a commit whose acknowledgment can be lost after the +// commit itself succeeded. +enum MaintenanceState { + MAINTENANCE_STATE_UNSPECIFIED = 0; + // The intent is durable and no target write has been attempted. Recovering + // from a crash here is free: nothing was written. + MAINTENANCE_STATE_PLANNED = 1; + // Target content exists and is not yet the authoritative answer. + MAINTENANCE_STATE_STAGED = 2; + // A commit was attempted and its outcome is not known. This is where a lost + // acknowledgment lands. It is neither success nor failure, and the whole + // reason the intent is written first is so this state can be left. + MAINTENANCE_STATE_COMMIT_UNKNOWN = 3; + MAINTENANCE_STATE_COMMITTED = 4; + // The committed target was read back and matched the intent. + MAINTENANCE_STATE_VALIDATED = 5; + // The workflow ended without committing, and that is known. + MAINTENANCE_STATE_FAILED = 6; + // Reconciliation ran and could not classify the outcome. Terminal until an + // operator acts. + MAINTENANCE_STATE_INDETERMINATE = 7; +} + +// IndeterminateDetail is why an outcome could not be classified. +// +// COMMIT_UNKNOWN and INDETERMINATE are deliberately different states. +// COMMIT_UNKNOWN says nobody has looked yet, and looking is a mechanical step +// the workflow performs on its own. INDETERMINATE says the workflow looked and +// the evidence does not decide. Indeterminate is a conclusion, not the absence +// of one, and collapsing the two would make an unattended retry loop +// indistinguishable from a problem that needs a human. +message IndeterminateDetail { + IndeterminateReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; + // What the intent said should be there. + StreamBoundary expected = 2; + // What was found. Unset means nothing was found, which is a different fact + // from finding an empty stream, and the two lead to opposite actions. + StreamBoundary observed = 3; + // For an operator. Never parsed. + string detail = 4; +} + +// IndeterminateReason is the specific evidence gap. +enum IndeterminateReason { + INDETERMINATE_REASON_UNSPECIFIED = 0; + // A target exists where the intent said one would, and its content is not the + // content this operation would have produced. Either something else wrote it + // or a prior attempt wrote a truncated copy. Never overwrite: this is the one + // reason that most invites a "just run it again" reflex and most punishes it. + INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH = 1; + // The target exists and could not be read well enough to compare. Unreadable + // is not absent, so nothing may be written on the strength of it. + INDETERMINATE_REASON_TARGET_UNREADABLE = 2; + // The source advanced between the intent and the commit, so the staged target + // is a transformation of a prefix. Committing it would silently discard every + // event appended in between. + INDETERMINATE_REASON_SOURCE_ADVANCED = 3; + // The source is no longer the stream incarnation the intent was cut from. + INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED = 4; + // The authoritative order of source events could not be established. + INDETERMINATE_REASON_ORDER_UNPROVEN = 5; + // Exclusive ownership of the target could not be proven, so a commit might + // overwrite a concurrent writer. + INDETERMINATE_REASON_OWNERSHIP_UNPROVEN = 6; + // No intent record was found for an operation that durable state shows was + // started. There is nothing to compare against, which is what skipping the + // intent-first rule costs. Named so its absence is a reportable condition + // rather than a mystery. + INDETERMINATE_REASON_INTENT_MISSING = 7; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/reconcile_migration.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/reconcile_migration.proto new file mode 100644 index 0000000000..5587e1849f --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/reconcile_migration.proto @@ -0,0 +1,53 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/migration.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/outcome.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto"; + +// ReconcileMigration resolves a migration whose commit outcome is unknown. +// +// It reads. There is no mode, no force, and no field that could make it write, +// for the same reason DiagnoseSession has none: a reconciler that can also +// commit is a reconciler that can blindly commit, and blindly copying a session +// again is precisely the failure this workflow exists to prevent. Acting on a +// verdict is a separate MigrateSession call, made by whoever read the verdict. +message ReconcileMigrationRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The identity from the recorded intent. Reconciliation compares against what + // was planned, so a caller with no intent has nothing to reconcile and gets + // INDETERMINATE_REASON_INTENT_MISSING rather than a guess. + MigrationIdentity identity = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +message ReconcileMigrationResponse { + ReconciliationVerdict verdict = 1 [features.field_presence = LEGACY_REQUIRED]; + // The state the record should be moved to. Reported rather than applied, + // because applying it is a write. + MaintenanceState resolved_state = 2 [features.field_presence = LEGACY_REQUIRED]; + // What was found at the target location. Unset when nothing was found. + StreamBoundary observed_target = 3; + // Set only for RECONCILIATION_VERDICT_UNRESOLVED. + IndeterminateDetail indeterminate = 4; + google.protobuf.Timestamp observed_at = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// ReconciliationVerdict is what the durable evidence says happened. +enum ReconciliationVerdict { + RECONCILIATION_VERDICT_UNSPECIFIED = 0; + // No target exists. The commit did not land, and a retry under the same + // identity is safe. + RECONCILIATION_VERDICT_NOT_COMMITTED = 1; + // A target exists and its boundary matches the intent exactly. The commit + // landed and the acknowledgment was the only thing lost. The correct action + // is to record success, not to migrate again. + RECONCILIATION_VERDICT_COMMITTED = 2; + // A target exists and does not match the intent. Fail closed: no automated + // action may resolve this, because both readings, a truncated copy of ours + // and an intact copy of somebody else's, look identical from here. + RECONCILIATION_VERDICT_DIVERGED = 3; + // The comparison itself could not be made. + RECONCILIATION_VERDICT_UNRESOLVED = 4; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage.proto new file mode 100644 index 0000000000..859d06b04f --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage.proto @@ -0,0 +1,160 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/outcome.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto"; + +// The durable record of a Session salvage. +// +// A salvage copies what can be read from a damaged session into a new session +// identity. It is the opposite of a migration on every axis that matters: +// +// | | migration | salvage | +// | identity | preserved | new | +// | ordinals | preserved exactly | not preserved | +// | source | must be intact | is damaged | +// | source after | replaced | untouched | +// | loss | inadmissible | expected and enumerated | +// +// It is also not ForkSession. A fork inherits a prefix it assumes is valid and +// references it in place, so the source must stay readable forever. A salvage +// exists because the source's validity is incomplete, so it copies, and the +// copy is a different session that must never be presented as the original. + +// SalvageIdentity is the retry identity of a salvage. +message SalvageIdentity { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Chosen by the operator or orchestrator. Two salvages of one damaged source + // are legitimately different operations, so identity cannot be derived from + // the source alone. + string salvage_key = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// SalvageIntent is written durably before the target session is created. +message SalvageIntent { + SalvageIdentity identity = 1 [features.field_presence = LEGACY_REQUIRED]; + StreamBoundary source = 2 [features.field_presence = LEGACY_REQUIRED]; + // The id the salvaged session will have, derived from the identity before any + // write is attempted. + // + // Deriving it is what makes a retry safe. The salvaged session is created by + // an atomic batch under a NoStream precondition, so a retry that lands on the + // same id sees a visible conflict instead of producing a second copy. A + // randomly minted id would leave a retry unable to find its own prior work, + // which is the same trap the migration reconciler exists to escape, closed + // here by the write precondition rather than by a later comparison. + string target_session_id = 3 [features.field_presence = LEGACY_REQUIRED]; + OrderProof order_proof = 4 [features.field_presence = LEGACY_REQUIRED]; + string actor = 5 [features.field_presence = LEGACY_REQUIRED]; + string reason = 6 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp planned_at = 7 [features.field_presence = LEGACY_REQUIRED]; +} + +// SalvageRecord is the intent plus everything learned since. +message SalvageRecord { + SalvageIntent intent = 1 [features.field_presence = LEGACY_REQUIRED]; + MaintenanceState state = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set only for MAINTENANCE_STATE_INDETERMINATE. + IndeterminateDetail indeterminate = 3; + // Everything the source held that the salvaged session does not. + repeated OmittedItem omitted = 4; + uint32 attempt_count = 5 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp updated_at = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// OmittedItem is one thing the salvage could not carry. +// +// Enumerated rather than counted. An operator told that three things were lost +// cannot tell whether they were three tool results or three user messages, and +// that difference decides whether the salvaged session is worth keeping. +message OmittedItem { + OmittedKind kind = 1 [features.field_presence = LEGACY_REQUIRED]; + // The source position, for an omission that had one. + uint64 source_ordinal = 2; + // The artifact, checkpoint, or child session id, for an omission that had one. + string entity_id = 3; + OmissionReason reason = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// OmittedKind is what sort of thing was lost. +enum OmittedKind { + OMITTED_KIND_UNSPECIFIED = 0; + OMITTED_KIND_EVENT = 1; + OMITTED_KIND_ARTIFACT = 2; + OMITTED_KIND_CHECKPOINT = 3; + OMITTED_KIND_CHILD_SESSION = 4; +} + +// OmissionReason is why it was lost. +enum OmissionReason { + OMISSION_REASON_UNSPECIFIED = 0; + // Present in the source and did not decode. + OMISSION_REASON_UNDECODABLE = 1; + // Referenced by the source and not there. + OMISSION_REASON_MISSING = 2; + // Present, and its content did not match its recorded digest. Deliberately + // never carried: a salvage that copied content failing its own integrity + // check would launder corruption into a session that looks healthy. + OMISSION_REASON_DIGEST_MISMATCH = 3; + // Present and could not be read well enough to verify. Not the same as + // absent, and not evidence of corruption, matching the doctor's three-way + // artifact observation. + OMISSION_REASON_UNVERIFIABLE = 4; + // Erased under a privacy obligation. It was not lost, and a salvage must not + // resurrect it. Recorded so the gap in the salvaged history is explained + // rather than read as further damage. + OMISSION_REASON_ERASED = 5; +} + +// SalvageResult is the disposition of one SalvageSession call. +// +// There is no separate "recovered with unverified artifacts" value, which is a +// deliberate departure from the shape Fx uses. History completeness and +// artifact verification are independent axes, and one flat enum forces the +// server to choose which of the two facts to report. The omissions carry both, +// and a second signal that could disagree with them would only invite a caller +// to pick. +enum SalvageResult { + SALVAGE_RESULT_UNSPECIFIED = 0; + // Every source event decoded and every referenced artifact verified. + SALVAGE_RESULT_COMPLETE = 1; + // A session was produced and items are missing. They are enumerated. + SALVAGE_RESULT_PARTIAL = 2; + // A prior attempt under this identity already produced the target session. + SALVAGE_RESULT_ALREADY_SALVAGED = 3; + // Refused before writing. Carries a RefusalDetail. + SALVAGE_RESULT_REFUSED = 4; + // The outcome could not be classified. + SALVAGE_RESULT_INDETERMINATE = 5; + // PLAN_ONLY: a salvage would run and nothing was written. The planned + // omissions are on the record, so an operator can see what would be lost + // before deciding. + SALVAGE_RESULT_WOULD_SALVAGE = 6; +} + +// RefusalDetail is why a salvage wrote nothing. +message RefusalDetail { + RefusalReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; + string detail = 2; +} + +// RefusalReason is the specific refusal. +enum RefusalReason { + REFUSAL_REASON_UNSPECIFIED = 0; + REFUSAL_REASON_SOURCE_NOT_FOUND = 1; + // Event order could not be established, so any session produced would be a + // plausible-looking transcript in an order that never happened. + REFUSAL_REASON_ORDER_UNPROVEN = 2; + // Nothing in the source could be read. An empty salvaged session would be a + // new artifact claiming provenance it cannot support. + REFUSAL_REASON_NOTHING_RECOVERABLE = 3; + // The source exceeds the limits allowed for one operation. + REFUSAL_REASON_SIZE_LIMIT = 4; + // A stream already exists at the derived target id and is not the target this + // identity would have produced. + REFUSAL_REASON_TARGET_DIVERGED = 5; + // Another maintenance operation holds this session. + REFUSAL_REASON_OPERATION_IN_PROGRESS = 6; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage_session.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage_session.proto new file mode 100644 index 0000000000..64522b0747 --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/salvage_session.proto @@ -0,0 +1,59 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/maintenance/v1alpha1/salvage.proto"; + +// SalvageSession copies what can be read from a damaged session into a new +// session identity, leaving the source untouched. +// +// Ordering of effects matches the migration and for the same reason: record the +// intent, stage the copied artifacts, create the target session as one atomic +// batch, validate. The source is never written to at any point, so a salvage +// that fails halfway costs a partially staged target and nothing else. +message SalvageSessionRequest { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Distinguishes this salvage from another salvage of the same source, and is + // what the target session id is derived from. A caller retrying a salvage + // must reuse it; a caller wanting a second, independent salvage must not. + string salvage_key = 2 [features.field_presence = LEGACY_REQUIRED]; + string actor = 3 [features.field_presence = LEGACY_REQUIRED]; + string reason = 4 [features.field_presence = LEGACY_REQUIRED]; + // Unset is PLAN_ONLY. + SalvageMode mode = 5; + // Workspace for the salvaged session. Needed only when the source's own + // workspace could not be read, which is exactly the case a damaged source + // makes likely. + string workspace_id = 6; + SalvageLimits limits = 7; +} + +// SalvageMode is whether this call may write. +enum SalvageMode { + SALVAGE_MODE_UNSPECIFIED = 0; + // Read the source, decide what would be carried, write nothing. + SALVAGE_MODE_PLAN_ONLY = 1; + SALVAGE_MODE_COMMIT = 2; +} + +// SalvageLimits bounds one call. +message SalvageLimits { + uint64 max_source_events = 1; + uint64 max_source_bytes = 2; + uint64 max_artifacts_verified = 3; + google.protobuf.Duration max_duration = 4; +} + +message SalvageSessionResponse { + SalvageResult result = 1 [features.field_presence = LEGACY_REQUIRED]; + // Always present, including on refusal. + SalvageRecord record = 2 [features.field_presence = LEGACY_REQUIRED]; + // The derived id, present even when nothing was written, so a caller can find + // the target of a call whose response it never received. + string target_session_id = 3 [features.field_presence = LEGACY_REQUIRED]; + // Set only for SALVAGE_RESULT_REFUSED. + RefusalDetail refused = 4; + google.protobuf.Timestamp observed_at = 5 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto b/proto/trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto new file mode 100644 index 0000000000..1e16a392df --- /dev/null +++ b/proto/trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto @@ -0,0 +1,63 @@ +edition = "2024"; + +package trogonai.session.sessions.maintenance.v1alpha1; + +// Value types shared by the Session maintenance workflows: migration and +// salvage. +// +// Redefined here rather than imported from the write side, following the rule +// ADR#0035 facet 3 applies to the state, projections, and checkpoints subtrees. +// A maintenance record outlives the schema it was written under -- that is the +// entire point of migration provenance -- so it must not be pinned to a +// write-side type that a migration is free to change. + +// StreamBoundary names an exact cut of one session's own logical stream: how +// far it extends and what the content at that extent is. +// +// Both workflows pin against one, and every indeterminate outcome is ultimately +// the statement that an observed boundary did not match an expected one. +message StreamBoundary { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The 1-indexed SessionOrdinal of the last event in the cut. Fold-derived, + // never a JetStream sequence, so it survives restore and relocation. + uint64 ordinal = 2 [features.field_presence = LEGACY_REQUIRED]; + ContentDigest content_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + // Which incarnation of the physical stream this cut was taken from: the + // subject token that isolates one incarnation's subject space from the next, + // per ADR#0059. Required, because an unset incarnation is not "the same + // incarnation" and a comparison against one can never fail. + // + // A migration's source names the retiring incarnation and its expected target + // names the new one. Two boundaries carrying different incarnations are not + // comparable by ordinal, and treating them as comparable is the failure + // INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED exists to report. + string incarnation = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// ContentDigest commits to the event bytes exactly as the log stores them. +// +// Never to a re-serialization. Protobuf encoding is not canonical, so a digest +// taken over a decode-then-re-encode round trip would not reproduce, and a +// workflow whose central check is "is this the same content" cannot be built on +// a comparison that fails against bytes the system itself wrote. +message ContentDigest { + string algorithm = 1 [features.field_presence = LEGACY_REQUIRED]; + bytes value = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// OrderProof is how well the authoritative order of a source cut is known. +// +// A salvage that cannot establish order cannot produce a session, because a +// transcript in the wrong order is worse than no transcript: it reads as +// authoritative and is wrong. +enum OrderProof { + ORDER_PROOF_UNSPECIFIED = 0; + // Every position from 1 to the boundary is present and decoded. + ORDER_PROOF_CONTIGUOUS = 1; + // Positions are missing, and every surviving event decoded and carries its + // own position, so the relative order of what survives is known. The missing + // positions are enumerated as omissions. + ORDER_PROOF_GAPPED = 2; + // Order could not be established. Fail closed. + ORDER_PROOF_UNPROVEN = 3; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/contract_version.proto b/proto/trogonai/session/sessions/queries/v1alpha1/contract_version.proto new file mode 100644 index 0000000000..ccc6c0c03a --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/contract_version.proto @@ -0,0 +1,47 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +// ContractVersion identifies a revision of the Session query contract. +// +// Every request declares the highest version its caller understands, and every +// response reports the version it was actually rendered at. Without both halves +// a client can only discover an incompatibility by failing to parse a response, +// which is exactly the outcome this contract exists to prevent. +// +// Compatibility rule: +// +// - Same `major`: compatible. Anything added within a major is additive, so a +// caller built against an earlier `minor` can still decode the response. +// - Different `major`: unsupported. The caller must not attempt to interpret +// the response, and the server must refuse the request with +// QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION rather than answer in a +// shape the caller cannot read. +// +// `minor` increments for additive changes only: a new optional field, a new +// enum value, a new variant in a discriminated union. `major` increments for +// anything a caller built against the prior version could misread: a removed +// field, a narrowed type, a changed meaning. +message ContractVersion { + // Incompatible revision. A caller must refuse a response whose major it does + // not know, rather than interpret the fields it happens to recognize. + uint32 major = 1 [features.field_presence = LEGACY_REQUIRED]; + // Additive revision within a major. + uint32 minor = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// ContractNegotiation is the version block every query response carries. +// +// It exists so that "the server understands more than I do" is a fact the +// caller reads, rather than something it infers from a field it cannot see. +message ContractNegotiation { + // The version this response was rendered at. It is never greater than the + // caller's declared `accepted_contract`, because the server clamps its output + // rather than emitting variants the caller cannot decode. + ContractVersion rendered = 1 [features.field_presence = LEGACY_REQUIRED]; + // The highest version this server can render. When it exceeds `rendered`, the + // caller is reading a deliberately narrowed view and an upgrade would show + // more; the elision counters on the response say whether anything was + // actually withheld from this particular answer. + ContractVersion server_max = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/get_session.proto b/proto/trogonai/session/sessions/queries/v1alpha1/get_session.proto new file mode 100644 index 0000000000..1471987a91 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/get_session.proto @@ -0,0 +1,37 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; +import "trogonai/session/sessions/queries/v1alpha1/read_consistency.proto"; +import "trogonai/session/sessions/queries/v1alpha1/session_view.proto"; + +// GetSessionRequest reads one session's detail view. +// +// The caller declares the contract version it understands. This is what turns +// an incompatibility into a typed refusal instead of a parse failure: the +// server can see, before rendering anything, whether the caller can read the +// answer. +message GetSessionRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The highest contract version this caller understands. The server renders at + // no higher than this, and refuses outright when the major does not match. + ContractVersion accepted_contract = 2 [features.field_presence = LEGACY_REQUIRED]; + // Freshness the caller requires. Unset is an eventual read. + ReadConsistency consistency = 3; +} + +// GetSessionResponse is a session's detail view. +// +// A failure is not a variant here. It arrives as a QueryError on the +// transport's error channel, so a caller can never read a zero-valued success +// shape as an empty answer. +message GetSessionResponse { + ContractNegotiation contract = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionView session = 2 [features.field_presence = LEGACY_REQUIRED]; + // How current the read model was when it answered. Always present, including + // on an eventual read, so currency is something the server stated rather than + // something the caller assumed. + ProjectionFreshness freshness = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/get_session_history.proto b/proto/trogonai/session/sessions/queries/v1alpha1/get_session_history.proto new file mode 100644 index 0000000000..5fe99417a7 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/get_session_history.proto @@ -0,0 +1,78 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/history_item.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; +import "trogonai/session/sessions/queries/v1alpha1/read_consistency.proto"; + +// GetSessionHistoryRequest reads one page of a session's history. +// +// History is a separate query from GetSession because it is unbounded. A detail +// read that inlined it would have no bound on its response size, and a client +// would have no way to ask for less. +message GetSessionHistoryRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ContractVersion accepted_contract = 2 [features.field_presence = LEGACY_REQUIRED]; + HistoryDirection direction = 3 [features.field_presence = LEGACY_REQUIRED]; + uint32 page_size = 4 [features.field_presence = LEGACY_REQUIRED]; + // Opaque continuation from a prior response, a serialized CursorEnvelope. + // Unset starts a new scan. `direction` is fixed when the scan opens, so a + // continuation that disagrees with the cursor is refused rather than + // reversed. + bytes page_token = 5; + // Freshness the caller requires. Honored when the scan opens and ignored on + // a continuation, whose contents are fixed by the anchor. A continuation + // asking for more than the scan was opened with is + // QUERY_ERROR_CODE_INVALID_ARGUMENT. + // + // This is the field that answers "does this transcript include the redaction + // I just applied". An eventual read cannot say, and the anchor alone cannot + // either: it says which ordinal the scan covers, not whether the projection + // had applied the event at that ordinal when the scan opened. + ReadConsistency consistency = 6; +} + +// HistoryDirection is which end of history a fresh scan starts from. +enum HistoryDirection { + HISTORY_DIRECTION_UNSPECIFIED = 0; + // Oldest first. + HISTORY_DIRECTION_FORWARD = 1; + // Newest first, the usual transcript-scrollback order. + HISTORY_DIRECTION_REVERSE = 2; +} + +// GetSessionHistoryResponse is one page of history items. +// +// The elision counters are the honest part of this message. A caller that reads +// only `items` cannot tell a complete page from one that quietly dropped half +// its content, and "the response parsed" is not evidence that it is complete. +message GetSessionHistoryResponse { + ContractNegotiation contract = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated HistoryItem items = 2; + // Unset when the scan is exhausted. Presence, not an empty `items` list, is + // the end signal. + bytes next_page_token = 3; + // Items on this page rendered as HISTORY_ITEM_KIND_ELIDED because they need a + // variant newer than the caller's contract minor. Non-zero means upgrading + // the caller would show more. + uint32 contract_clamped_count = 4 [features.field_presence = LEGACY_REQUIRED]; + // Items on this page whose content was withheld by redaction or + // authorization. Distinct from the clamped count: upgrading the caller will + // not reveal these, and a client should not prompt for an upgrade. + uint32 withheld_count = 5 [features.field_presence = LEGACY_REQUIRED]; + // The effective history boundary this page was rendered against, after + // rewind masking, as a SessionOrdinal. It is the scan's anchor and is equal + // on every page of one scan. + // + // Turns appended after the scan opened are above this boundary and are not + // in it. That is the property that keeps paging stable while a session is + // still being written to, and it means an in-progress scan is not how a + // caller learns about new turns. Should the effective boundary itself move, + // by rewind or redaction, the continuation fails with STALE_CURSOR rather + // than quietly reporting a different value here. + uint64 effective_through = 6 [features.field_presence = LEGACY_REQUIRED]; + // How current the read model was when the scan opened. Equal on every page. + ProjectionFreshness freshness = 7 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/history_item.proto b/proto/trogonai/session/sessions/queries/v1alpha1/history_item.proto new file mode 100644 index 0000000000..e7296d7b52 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/history_item.proto @@ -0,0 +1,176 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +// HistoryItem is one entry in a session's reader-visible history. +// +// The discriminated-union hazard this shape is built around: a caller decoding +// a `oneof` arm added after its contract minor sees an unset `oneof` and cannot +// distinguish "a variant I do not know" from "a variant that was not set". +// Silently rendering nothing for a real event is a correctness failure, not a +// cosmetic one. +// +// Two mechanisms close that gap: +// +// 1. `kind` is a plain enum outside the `oneof`. Proto enums are open, so an +// unrecognized kind decodes as its raw number rather than vanishing, and a +// caller can always tell that something is here it does not understand. +// 2. The server clamps to the caller's declared contract minor and emits +// HISTORY_ITEM_KIND_ELIDED with an `elided` payload rather than a variant +// the caller cannot decode. Elision is affirmative: the caller reads that +// an item was withheld instead of inferring it from an empty field. +message HistoryItem { + // Stable within a session, opaque, and safe to use as a rendering key. It + // remains stable across an elision, so a client that upgrades sees the same + // item resolve to a real variant. + string item_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The session's own 1-indexed position for this item. + uint64 ordinal = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set even when the matching `item` arm is absent, so an unknown or withheld + // item is still identifiable. + HistoryItemKind kind = 3 [features.field_presence = LEGACY_REQUIRED]; + oneof item { + UserMessageItem user_message = 4; + AssistantMessageItem assistant_message = 5; + ToolCallItem tool_call = 6; + FileChangeItem file_change = 7; + SystemNoticeItem system_notice = 8; + CompactionItem compaction = 9; + HistoryItemElided elided = 10; + } +} + +// HistoryItemKind is what an item is, readable without decoding the union. +enum HistoryItemKind { + HISTORY_ITEM_KIND_UNSPECIFIED = 0; + HISTORY_ITEM_KIND_USER_MESSAGE = 1; + HISTORY_ITEM_KIND_ASSISTANT_MESSAGE = 2; + HISTORY_ITEM_KIND_TOOL_CALL = 3; + HISTORY_ITEM_KIND_FILE_CHANGE = 4; + HISTORY_ITEM_KIND_SYSTEM_NOTICE = 5; + HISTORY_ITEM_KIND_COMPACTION = 6; + // The item exists but was not rendered. `elided` says why. + HISTORY_ITEM_KIND_ELIDED = 7; +} + +// HistoryItemElided is an item the server chose not to render, stated +// affirmatively so a caller never mistakes a withheld item for a missing one. +message HistoryItemElided { + ElisionReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; +} + +// ElisionReason is why an item was withheld. +enum ElisionReason { + ELISION_REASON_UNSPECIFIED = 0; + // The item needs a variant introduced after the caller's contract minor. + // Upgrading the caller resolves it. + ELISION_REASON_CONTRACT_CLAMPED = 1; + // A redaction masked the item's content. The item's existence is still a + // fact; only the content is gone. + ELISION_REASON_REDACTED = 2; + // The caller is not authorized to see this item's content. + ELISION_REASON_NOT_AUTHORIZED = 3; +} + +// UserMessageItem is a message from the user. +message UserMessageItem { + string turn_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Rendered plain text. Structured and provider-native content is reachable + // through the artifact surface, not inlined here. + string text = 2 [features.field_presence = LEGACY_REQUIRED]; + // The text was shortened for transport. The full content is not recoverable + // from this response. + bool truncated = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// AssistantMessageItem is one assistant generation and its outcome. +// +// It carries a terminal state rather than a completion flag, because a +// generation that was interrupted is a different fact from one still running, +// and a boolean cannot hold that difference. +message AssistantMessageItem { + string turn_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string model = 2 [features.field_presence = LEGACY_REQUIRED]; + string text = 3 [features.field_presence = LEGACY_REQUIRED]; + bool truncated = 4 [features.field_presence = LEGACY_REQUIRED]; + AssistantMessageOutcome outcome = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// AssistantMessageOutcome is how a generation ended. +enum AssistantMessageOutcome { + ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED = 0; + // Started, with no terminal fact recorded. Either still running or stranded + // by a crash; the reader cannot tell which, and must not present it as done. + ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT = 1; + ASSISTANT_MESSAGE_OUTCOME_COMPLETED = 2; + ASSISTANT_MESSAGE_OUTCOME_FAILED = 3; +} + +// ToolCallItem is one tool call and its lifecycle position. +message ToolCallItem { + string turn_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_name = 3 [features.field_presence = LEGACY_REQUIRED]; + ToolCallOutcome outcome = 4 [features.field_presence = LEGACY_REQUIRED]; + // True when the call started and no terminal outcome was ever recorded. This + // is the reader-visible form of an interrupted call awaiting reconciliation. + bool unreconciled = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// ToolCallOutcome is where a tool call stopped. +enum ToolCallOutcome { + TOOL_CALL_OUTCOME_UNSPECIFIED = 0; + TOOL_CALL_OUTCOME_REQUESTED = 1; + TOOL_CALL_OUTCOME_APPROVED = 2; + TOOL_CALL_OUTCOME_DENIED = 3; + // Running, or stranded by a crash. See `unreconciled`. + TOOL_CALL_OUTCOME_STARTED = 4; + TOOL_CALL_OUTCOME_COMPLETED = 5; + TOOL_CALL_OUTCOME_FAILED = 6; +} + +// FileChangeItem is one workspace file change attributed to a tool call. +message FileChangeItem { + string turn_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Workspace-relative, forward slashes, no leading slash. + string path = 3 [features.field_presence = LEGACY_REQUIRED]; + FileChangeKindView change_kind = 4 [features.field_presence = LEGACY_REQUIRED]; + // Set only for a rename. + string previous_path = 5; +} + +// FileChangeKindView is what happened to a file. +enum FileChangeKindView { + FILE_CHANGE_KIND_VIEW_UNSPECIFIED = 0; + FILE_CHANGE_KIND_VIEW_CREATED = 1; + FILE_CHANGE_KIND_VIEW_MODIFIED = 2; + FILE_CHANGE_KIND_VIEW_DELETED = 3; + FILE_CHANGE_KIND_VIEW_RENAMED = 4; +} + +// SystemNoticeItem is a system-originated notice surfaced in the transcript. +message SystemNoticeItem { + NoticeLevelView level = 1 [features.field_presence = LEGACY_REQUIRED]; + string text = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// NoticeLevelView is a notice's severity. +enum NoticeLevelView { + NOTICE_LEVEL_VIEW_UNSPECIFIED = 0; + NOTICE_LEVEL_VIEW_INFO = 1; + NOTICE_LEVEL_VIEW_WARNING = 2; + NOTICE_LEVEL_VIEW_ERROR = 3; +} + +// CompactionItem marks where a range of history was replaced by a summary. +// +// It is surfaced rather than hidden so a reader can see that the transcript it +// is looking at is not the whole transcript. +message CompactionItem { + // Inclusive ordinal range this summary stands in for. + uint64 covers_from = 1 [features.field_presence = LEGACY_REQUIRED]; + uint64 covers_through = 2 [features.field_presence = LEGACY_REQUIRED]; + string summary_text = 3 [features.field_presence = LEGACY_REQUIRED]; + bool truncated = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/latest_session.proto b/proto/trogonai/session/sessions/queries/v1alpha1/latest_session.proto new file mode 100644 index 0000000000..889a894a27 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/latest_session.proto @@ -0,0 +1,126 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; +import "trogonai/session/sessions/queries/v1alpha1/read_consistency.proto"; +import "trogonai/session/sessions/queries/v1alpha1/session_view.proto"; + +// GetLatestSessionRequest asks for the one newest session matching a selector. +// +// A resume command wants a single session, and getting it by listing a page and +// taking the first row is wrong in a way that only shows up under load: the +// list is ordered by recency but filtered afterwards, so a workspace whose most +// recent forty sessions are all ineligible returns a page with no answer in it +// and no indication that a longer page would have found one. Selection has to +// happen in the index, not in the caller. +// +// This is also the query where staleness costs the most. A stale list is a list +// with an old row in it, which a human reading a picker can notice. A stale +// latest-pointer is the one answer the caller acts on, so the whole error lands +// on the session that gets opened. +message GetLatestSessionRequest { + string workspace_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ContractVersion accepted_contract = 2 [features.field_presence = LEGACY_REQUIRED]; + // Which session counts as the answer. + SessionSelector selector = 3 [features.field_presence = LEGACY_REQUIRED]; + // Which timestamp "latest" is measured by. + RecencyBasis recency = 4 [features.field_presence = LEGACY_REQUIRED]; + // Freshness the caller requires. Unset is an eventual read. + ReadConsistency consistency = 5; +} + +// GetLatestSessionResponse is the single newest matching session, or nothing. +message GetLatestSessionResponse { + ContractNegotiation contract = 1 [features.field_presence = LEGACY_REQUIRED]; + // Unset when nothing in the workspace matched. Absence is the answer, not an + // error: a workspace with no resumable session is a normal state, and + // reporting it as a failure would make a first-run workspace look broken. + SessionSummary session = 2; + // What the selector rejected on the way to that answer. Always present, + // including when a session was found. + // + // This is what makes an empty answer diagnosable. "No resumable session" and + // "eleven sessions, all still running" are the same absence to a caller that + // only sees the empty field, and they call for opposite next moves: create a + // new session, or attach to a running one. + ExclusionCounts excluded = 3 [features.field_presence = LEGACY_REQUIRED]; + ProjectionFreshness freshness = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// SessionSelector is which session in a workspace counts as the answer. +// +// An enum rather than a set of filter booleans. Booleans let a caller ask for a +// session that is both currently active and not currently active, and the +// server then has to decide what an impossible request means. Every value here +// is a question someone actually asks. +enum SessionSelector { + // No selector given. Refused with QUERY_ERROR_CODE_INVALID_ARGUMENT. + // + // The zero value does not default to a selector, because the two callers of + // this query want different ones and both are plausible defaults: a picker + // wants the most recent session of any kind, and a resume wants a resumable + // one. Guessing wrong hands a resume command a session that is already + // running somewhere else. + SESSION_SELECTOR_UNSPECIFIED = 0; + // The newest non-archived session, whatever state it is in. + SESSION_SELECTOR_MOST_RECENT = 1; + // The newest session a resume can attach to: not archived, not currently + // active, not empty, and not hidden. + // + // Terminal is not an exclusion. A closed session is the ordinary thing to + // resume; that is what resuming means. What is excluded is a session already + // being driven from somewhere else, which resuming would turn into two + // writers on one stream. + SESSION_SELECTOR_RESUMABLE = 2; + // The newest session currently being driven. Answers "reattach me to what I + // was doing" without a resume's exclusions. + SESSION_SELECTOR_ACTIVE = 3; +} + +// RecencyBasis is which timestamp "latest" is measured by. +// +// The two orderings disagree often enough to matter: a long session started +// yesterday and worked on this morning is the newest by activity and among the +// oldest by creation. Every timestamp behind this is a recorded external +// occurrence and not the moment an envelope was appended (D10), so a projection +// that catches up late does not reorder the answer. +enum RecencyBasis { + // Unset. Treated as LAST_ACTIVITY, which is what a resume means by "latest". + RECENCY_BASIS_UNSPECIFIED = 0; + // Most recent effective history activity. + RECENCY_BASIS_LAST_ACTIVITY = 1; + // Session creation. + RECENCY_BASIS_CREATED = 2; +} + +// ExclusionCounts is how many candidate sessions each rule removed. +// +// A session removed by more than one rule is counted once, under the first rule +// that removed it, in the order the fields are declared. Counting it under +// every matching rule would produce totals that exceed the workspace, and the +// number a caller wants is how many sessions there were, not how many +// judgements were made. +message ExclusionCounts { + // Sessions in the workspace the caller may see. The denominator; zero here + // means an empty workspace rather than an over-strict selector. + uint32 considered = 1 [features.field_presence = LEGACY_REQUIRED]; + uint32 archived = 2 [features.field_presence = LEGACY_REQUIRED]; + // Excluded because something is currently driving them. + uint32 active = 3 [features.field_presence = LEGACY_REQUIRED]; + // Excluded because their effective history contains no user-authored turn. + // + // Emptiness is defined on authored content, not on `effective_length`. A + // session can carry configuration and lifecycle records and still be one + // nobody ever said anything in, and a rewind back to the start empties a + // session that was not empty an hour ago. Resuming one of those puts a person + // back into a blank window they have no memory of leaving. + uint32 empty = 4 [features.field_presence = LEGACY_REQUIRED]; + // Excluded by TERMINAL_REASON_HIDDEN. + uint32 hidden = 5 [features.field_presence = LEGACY_REQUIRED]; + // Excluded because the projection could not render the row. Non-zero means + // the answer may be wrong rather than merely empty: the session that should + // have won might be one of these. + uint32 unrenderable = 6 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/list_sessions.proto b/proto/trogonai/session/sessions/queries/v1alpha1/list_sessions.proto new file mode 100644 index 0000000000..8996f24144 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/list_sessions.proto @@ -0,0 +1,85 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; +import "trogonai/session/sessions/queries/v1alpha1/read_consistency.proto"; +import "trogonai/session/sessions/queries/v1alpha1/session_view.proto"; + +// ListSessionsRequest enumerates sessions in a scope, newest first. +message ListSessionsRequest { + ContractVersion accepted_contract = 1 [features.field_presence = LEGACY_REQUIRED]; + ListSessionsScope scope = 2 [features.field_presence = LEGACY_REQUIRED]; + // Required for SCOPE_WORKSPACE, ignored otherwise. + string workspace_id = 3; + ArchivedFilter archived = 4 [features.field_presence = LEGACY_REQUIRED]; + // Maximum rows to return. The server may return fewer. A value above the + // configured admission limit is refused with + // QUERY_ERROR_CODE_RESOURCE_EXHAUSTED rather than silently clamped, so a + // caller is never left believing it asked for more than it received. + uint32 page_size = 5 [features.field_presence = LEGACY_REQUIRED]; + // Opaque continuation from a prior response, a serialized CursorEnvelope. + // Unset starts a new scan. The caller must treat this as bytes and never + // construct, parse, or edit one. + // + // A continuation still carries the scope, workspace, and archived filter, and + // they must match what the cursor was minted with. The server refuses a + // disagreement rather than re-scoping the scan in flight. + bytes page_token = 6; + // Freshness the caller requires. Honored when the scan opens and ignored on + // a continuation, because a continuation is served from the pinned watermark + // and waiting for anything newer could not change what it returns. + // + // A continuation whose requirement is stricter than the one the scan was + // opened with is QUERY_ERROR_CODE_INVALID_ARGUMENT. Silently ignoring it + // would let a caller believe a later page reflects a write that it cannot. + ReadConsistency consistency = 7; +} + +// ListSessionsScope is which sessions are in range. +enum ListSessionsScope { + LIST_SESSIONS_SCOPE_UNSPECIFIED = 0; + // Sessions bound to one workspace. + LIST_SESSIONS_SCOPE_WORKSPACE = 1; + // Every session the caller may see, across workspaces. + LIST_SESSIONS_SCOPE_ALL = 2; +} + +// ArchivedFilter is how archived sessions are treated. +// +// A tri-state rather than a boolean, because "exclude archived" and "archived +// only" are both real views and a boolean can only express one of them +// alongside the default. +enum ArchivedFilter { + ARCHIVED_FILTER_UNSPECIFIED = 0; + ARCHIVED_FILTER_EXCLUDE = 1; + ARCHIVED_FILTER_INCLUDE = 2; + ARCHIVED_FILTER_ONLY = 3; +} + +// ListSessionsResponse is one page of session summaries. +message ListSessionsResponse { + ContractNegotiation contract = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated SessionSummary sessions = 2; + // Unset when this is the last page. Presence, not an empty `sessions` list, + // is the end-of-scan signal: a page may legitimately be empty while more + // pages remain. + bytes next_page_token = 3; + // Rows the server could not decode or render and therefore skipped. A + // non-zero count means this page is incomplete, and a caller must not read + // the result as an exhaustive list. Reporting zero is not the same as not + // reporting. + uint32 skipped_count = 4 [features.field_presence = LEGACY_REQUIRED]; + // The projection position this scan is pinned to, equal on every page of one + // scan. It is the scan anchor, not a freshness report. + // + // A scan enumerates the ordering as it stood here, so a session that entered + // the scope afterwards is not in it and will not appear on a later page. A + // caller that needs newer rows starts a new scan; it does not keep paging and + // wait for them to show up. + uint64 pinned_watermark = 5 [features.field_presence = LEGACY_REQUIRED]; + // How current the read model was when the scan opened. Equal on every page, + // since a pinned scan does not become fresher as it is paged. + ProjectionFreshness freshness = 6 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/page_cursor.proto b/proto/trogonai/session/sessions/queries/v1alpha1/page_cursor.proto new file mode 100644 index 0000000000..30bcd42493 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/page_cursor.proto @@ -0,0 +1,164 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/get_session_history.proto"; +import "trogonai/session/sessions/queries/v1alpha1/list_sessions.proto"; + +// CursorEnvelope is what a `page_token` actually contains. +// +// These types are server-minted internals. They are published so the format is +// reviewable and versioned, not so callers can read it: a client must treat a +// token as opaque bytes and never construct, parse, or edit one. The server +// owes nothing to a hand-built token beyond QUERY_ERROR_CODE_MALFORMED_CURSOR. +// +// The envelope keeps `payload` as bytes rather than an inline message on +// purpose. `mac` authenticates the exact bytes the server emitted, and protobuf +// serialization is not canonical, so a server that re-encoded a decoded message +// to check the MAC could compute a different byte string than it signed. +message CursorEnvelope { + // Version of this envelope and payload format, independent of the query + // ContractVersion. A token minted under an unknown format_version is + // MALFORMED_CURSOR, not STALE_CURSOR: there is nothing to interpret. + uint32 format_version = 1 [features.field_presence = LEGACY_REQUIRED]; + // Serialized PageCursor. + bytes payload = 2 [features.field_presence = LEGACY_REQUIRED]; + // Authenticates format_version and payload under a server-held key. + // + // A cursor names a scan position, so an unauthenticated one is a request + // parameter the caller controls. The MAC is what stops a caller from moving + // the anchor, widening the selector, or pointing a scan at another session's + // stream. It is tamper evidence and nothing more: a cursor is never + // authorization, and every continuation is re-authorized from the caller's + // own identity as if it were a fresh request. + bytes mac = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// PageCursor is the decoded scan position. +message PageCursor { + // When the scan variant does not match the query it was presented to, the + // token is MALFORMED_CURSOR. A history cursor is not a list cursor with + // different fields set. + oneof scan { + HistoryScanCursor history = 1; + SessionListScanCursor session_list = 2; + } + // When the token stops being honored regardless of validity. + // + // A pinned scan holds read-model retention (see CursorValidity), so scans + // cannot be allowed to live forever. Expiry is STALE_CURSOR with + // STALE_CURSOR_REASON_EXPIRED, because restarting the scan is the fix. + google.protobuf.Timestamp expires_at = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// HistoryScanCursor is a position within one session's history. +// +// This is the message that makes the paging guarantee true. History is +// append-only and every item carries a SessionOrdinal that is assigned once and +// never renumbered, so a position expressed as an ordinal keeps its meaning as +// the session grows. A position expressed as an offset from either end does +// not, which is why the count of items is deliberately absent here. +message HistoryScanCursor { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Contract the scan was opened at. The server keeps rendering at this version + // for the life of the scan so a page is not shaped differently from its + // predecessors. A continuation presenting a different major is + // STALE_CURSOR_REASON_CONTRACT_CHANGED. + ContractVersion minted_contract = 2 [features.field_presence = LEGACY_REQUIRED]; + // Fixed for the life of the scan. A continuation cannot reverse it; that is a + // new scan. + HistoryDirection direction = 3 [features.field_presence = LEGACY_REQUIRED]; + // The effective-history head the scan was pinned to when it opened, as a + // SessionOrdinal. + // + // The scan never looks past this, and that is what makes concurrent appends + // harmless: a turn recorded after the scan opened is outside the window + // rather than shifting rows inside it. A reverse scan walking toward older + // history is unaffected by definition; a forward scan ends here even if newer + // items exist by the time it arrives. + uint64 anchor_ordinal = 4 [features.field_presence = LEGACY_REQUIRED]; + // The last SessionOrdinal delivered. The next page resumes strictly past it + // in `direction`, which is why an item can be neither repeated nor skipped: + // the boundary is the identity of a delivered row, not a count of them. + uint64 last_delivered_ordinal = 5 [features.field_presence = LEGACY_REQUIRED]; + CursorValidity validity = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// SessionListScanCursor is a position within a list scan. +message SessionListScanCursor { + ContractVersion minted_contract = 1 [features.field_presence = LEGACY_REQUIRED]; + ListScanSelector selector = 2 [features.field_presence = LEGACY_REQUIRED]; + // Last row delivered. The next page resumes strictly after it in the scan's + // ordering. + SessionOrderingKey last_delivered = 3 [features.field_presence = LEGACY_REQUIRED]; + CursorValidity validity = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// ListScanSelector is the request shape the scan was opened with. +// +// A continuation whose request disagrees with this is MALFORMED_CURSOR rather +// than a silently re-scoped scan. Changing the scope, workspace, or archived +// filter mid-scan produces a page sequence that is neither the old selection +// nor the new one, and the caller has no way to notice. +message ListScanSelector { + ListSessionsScope scope = 1 [features.field_presence = LEGACY_REQUIRED]; + string workspace_id = 2; + ArchivedFilter archived = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// SessionOrderingKey is one row's position in the list ordering. +// +// Ordering is by `ordering_value` descending, then `session_id` ascending. The +// tie-breaker is not decoration: ordering values collide, and a boundary that +// cannot distinguish two rows sharing one must either re-emit both or drop +// both. +message SessionOrderingKey { + // The row's ordering value as of the scan's pinned watermark, not as of now. + // + // Recency ordering is the thing a session picker wants and is also mutable, a + // combination that breaks naive pagination: a row that gains activity after + // the cursor has passed its old position jumps ahead of the cursor and is + // never delivered. Reading the ordering as of a fixed watermark is what + // removes that skip, and it is an obligation on the list projection rather + // than something this contract can assert by itself. + uint64 ordering_value = 1 [features.field_presence = LEGACY_REQUIRED]; + string session_id = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// CursorValidity is everything a cursor binds to besides its position. +// +// Each field answers one question: is the sequence this cursor was cut from +// still the same sequence? A change in any of them means resuming would produce +// a page sequence that never existed as a whole, so the server refuses with +// QUERY_ERROR_CODE_STALE_CURSOR and the matching StaleCursorReason instead of +// serving a plausible page. +message CursorValidity { + // Identifies the projection instance. A rebuild under a new generation makes + // ordering values from the old one meaningless. + // Mismatch: STALE_CURSOR_REASON_PROJECTION_REPLACED. + string projection_generation = 1 [features.field_presence = LEGACY_REQUIRED]; + // The projection position the scan is pinned to. Constant across every page + // of one scan. + // + // A pinned scan requires the projection to still be able to answer as of this + // point, which is what cursor expiry bounds. + uint64 pinned_watermark = 2 [features.field_presence = LEGACY_REQUIRED]; + // Bumped whenever the set of effective events changes shape: rewind, which + // retracts history the scan may already have passed, and compaction, which + // replaces a span with a summary. Either leaves a cursor describing a prefix + // that no longer exists. + // + // Mismatch is STALE_CURSOR_REASON_REWOUND or STALE_CURSOR_REASON_COMPACTED + // depending on which change advanced it, so the server must know the cause of + // an advance and not only that one happened. The distinction matters to a + // caller: a compaction lost nothing, a rewind did. + uint64 effective_history_revision = 3 [features.field_presence = LEGACY_REQUIRED]; + // Bumped by redaction and artifact erasure. Tracked separately from + // effective_history_revision because it is the field that must be checked + // even when nothing else moved: continuing to serve a scan cut before an + // erasure would keep handing out content that was ordered destroyed. + // Mismatch: STALE_CURSOR_REASON_PRIVACY_CHANGED. + uint64 privacy_revision = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto b/proto/trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto new file mode 100644 index 0000000000..13e796ada5 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto @@ -0,0 +1,139 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; + +// PresentationCacheBinding is the projection state a client-side cache was +// rendered against. +// +// A client that reopens a session wants to paint the timeline before the first +// query returns. The cached copy is only safe to paint if the projection it +// came from still exists and still says the same things. This message is what +// the cache stores alongside its rendered content so that question has an +// answer other than a guess about elapsed time. +// +// The four projection coordinates are the same four a page cursor pins in +// `CursorValidity`, because the events that invalidate a cursor and the events +// that invalidate a cache are the same events. They are separate messages +// rather than one shared one because they are checked by different parties: a +// cursor is minted by the server, opaque to the client, and validated by the +// server on the next page; a binding is held by the client, readable by the +// client, and checked before anything is painted. Sharing the type would make +// a change made for one validator's benefit land on the other's. +// +// Nothing here describes the rendering itself. Terminal width, scroll position, +// theme, and ANSI handling are the client's state and stay in the client: the +// Session event log records what happened, not what a viewer looked like while +// watching it, and a projection that stored presentation state would be one +// that has to be rebuilt every time a renderer changes. +message PresentationCacheBinding { + // The projection instance that produced the cached content. A projection + // rebuild mints a new generation, and content from the old one is not a + // stale version of the new one, it is output from a different computation. + string projection_generation = 1 [features.field_presence = LEGACY_REQUIRED]; + // Stream position the projection had applied through when it rendered this. + uint64 processed_watermark = 2 [features.field_presence = LEGACY_REQUIRED]; + // Revision of the session's effective history, bumped by rewind and by + // compaction. + // + // This is the field that makes "my cache is just older" checkable rather than + // assumed. A cache at a lower watermark is a safe prefix of the current view + // only when history is append-only between the two positions. Rewind and + // compaction retract content that was there, so after either one a lower + // watermark is not a prefix of a higher one and the cache is wrong rather + // than incomplete. + uint64 effective_history_revision = 3 [features.field_presence = LEGACY_REQUIRED]; + // Revision of the session's privacy state, bumped by redaction and by + // artifact erasure. + // + // Tracked apart from history because it is the one that must be checked even + // when nothing else moved, and because getting it wrong is not a staleness + // annoyance. A cache painted after a redaction shows content someone + // deliberately destroyed, on a screen, to a person, which is the failure the + // redaction was performed to prevent. + uint64 privacy_revision = 4 [features.field_presence = LEGACY_REQUIRED]; + // Query contract version the cached content was rendered at. A cache built + // from a response the current contract would render differently is not + // reusable even when every projection coordinate still matches. + ContractVersion contract_version = 5 [features.field_presence = LEGACY_REQUIRED]; + // Opaque identifier for the client-side rendering code that produced the + // cached content. + // + // The server never interprets it and never compares it. It is carried so a + // client that ships a new renderer can discard its own caches without the + // server having to know anything about renderers, which is the arrangement + // that keeps rendering changes from being a server deployment. + string renderer_version = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// CheckPresentationCacheRequest asks whether a held cache may still be shown. +// +// It is deliberately not a read. A caller that wanted the content would call +// GetSessionHistory; this exists for the caller that already has content and +// needs a verdict cheaper than fetching it again. There is no field here that +// could make it return timeline data, so it cannot quietly become the +// expensive path it was added to avoid. +message CheckPresentationCacheRequest { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ContractVersion accepted_contract = 2 [features.field_presence = LEGACY_REQUIRED]; + // What the held cache was rendered against. + PresentationCacheBinding binding = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// CheckPresentationCacheResponse is the verdict on a held cache. +message CheckPresentationCacheResponse { + ContractNegotiation contract = 1 [features.field_presence = LEGACY_REQUIRED]; + CacheUsability usability = 2 [features.field_presence = LEGACY_REQUIRED]; + // What a cache rendered now would be bound to. + // + // Present on every verdict, including a discard, so a client that is about to + // refetch knows what to bind the replacement to without a second round trip. + PresentationCacheBinding current = 3 [features.field_presence = LEGACY_REQUIRED]; + // How current the projection that answered was. A usable verdict from a + // lagging projection is a verdict about a lagging view, and the caller is + // owed that distinction. + ProjectionFreshness freshness = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// CacheUsability is what a client may do with the cache it holds. +// +// The values are ordered by how much of the cache survives, and the zero value +// is the one that discards, so a client that reads a variant it does not know +// falls back to fetching rather than to painting. +enum CacheUsability { + // Unknown verdict. Treat as DISCARD. + CACHE_USABILITY_UNSPECIFIED = 0; + // Every coordinate matches. The cache is the current view and may be painted + // as final. + CACHE_USABILITY_CURRENT = 1; + // The cache is a strict prefix: same generation, same history revision, same + // privacy revision, lower watermark. + // + // It may be painted immediately and then extended by reading forward from + // `binding.processed_watermark`. This is the only variant that lets a client + // show something before its first query returns, and it is gated on the + // revisions rather than on the watermark, because a lower watermark alone + // does not establish that the interval between them only added. + CACHE_USABILITY_APPENDABLE = 2; + // Content the cache holds no longer exists, because a rewind, a compaction, a + // redaction, or an artifact erasure removed it. + // + // Distinct from REPLACED because the projection is fine; the history changed + // underneath it. Distinct from STALE because there is no safe subset: the + // client cannot know which of its rows were the retracted ones, so it + // discards all of them. + CACHE_USABILITY_RETRACTED = 3; + // The projection generation differs. The cache came from a computation that + // no longer runs, so it is not old output, it is foreign output. + CACHE_USABILITY_REPLACED = 4; + // The contract major or the renderer version differs from what a fresh render + // would use. The content may still be accurate and is still not reusable. + CACHE_USABILITY_INCOMPATIBLE = 5; + // The server could not decide, because its own projection state is unknown to + // it. Reported rather than resolved to DISCARD so a client can tell a cache + // that was rejected from a cache that was never judged, and so a degraded + // server does not silently trigger a refetch storm it cannot serve. + CACHE_USABILITY_INDETERMINATE = 6; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto b/proto/trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto new file mode 100644 index 0000000000..35f9672587 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto @@ -0,0 +1,125 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "google/protobuf/timestamp.proto"; + +// ProjectionFreshness is how current the read model was when it answered. +// +// Every successful Session query carries one. A response that parses is not +// evidence that it reflects a write the caller just made, and a caller with no +// way to tell will present a stale view as the truth. Reporting freshness on +// every answer, rather than only when something is wrong, is what makes "this +// is current" a statement the server made instead of one the caller assumed. +// +// This is query metadata. None of it is derived from Session events, and none +// of it belongs in one: it describes the read path's progress, which is not a +// fact about the session. +message ProjectionFreshness { + ProjectionCondition condition = 1 [features.field_presence = LEGACY_REQUIRED]; + // Identifies the projection instance. A rebuild under a new generation + // invalidates positions and orderings minted against the old one, which is + // what page cursors bind to (see CursorValidity). + string projection_generation = 2 [features.field_presence = LEGACY_REQUIRED]; + // How far the projection has applied. For a session-scoped read this is a + // SessionOrdinal on that session's stream, which is what a ConsistencyToken + // is compared against. + uint64 processed_watermark = 3 [features.field_presence = LEGACY_REQUIRED]; + // Event time of the last applied event. Useful for a human-facing "as of", + // and useless as a consistency boundary: event time is not monotonic across + // writers, so a caller must compare watermarks, not timestamps. + google.protobuf.Timestamp processed_at = 4; + // The source stream head as most recently observed. + // + // Unset means the head was not observed for this read, which is not the same + // as a head of zero. Observing it costs a round trip the read path does not + // always pay, so the contract lets a server decline rather than report a + // fabricated value. When it is unset the condition is INDETERMINATE. + uint64 source_high_watermark = 5; + // When source_high_watermark was observed. A cached observation is still + // useful and still needs its age disclosed, because lag computed against a + // stale head understates the real lag. + google.protobuf.Timestamp source_observed_at = 6; + ConsistencyOutcome consistency = 7 [features.field_presence = LEGACY_REQUIRED]; + AnswerSource source = 8 [features.field_presence = LEGACY_REQUIRED]; +} + +// AnswerSource is what actually produced this answer. +// +// A projection that cannot serve does not have to mean the read fails. For a +// read scoped to one session the server can fold that session's stream directly +// and answer from the log, which is the authoritative source the projection is +// only a cache of. The caller needs to be told, because the answer is better +// than a projection answer and more expensive than one, and because a few +// things it would normally be allowed to do with the response no longer hold. +// +// Falling back is admissible only for a session-scoped read. A read across +// sessions has no bounded stream to fold, so a list query has exactly two +// honest outcomes: a projection answer, or +// QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE. Stating that here is cheaper than +// discovering it the first time a degraded list query tries to replay a +// tenant. +enum AnswerSource { + ANSWER_SOURCE_UNSPECIFIED = 0; + // Served from the materialized read model. + ANSWER_SOURCE_PROJECTION = 1; + // Served by folding the session's own stream, because the projection could + // not answer. + // + // The condition is CURRENT, since the fold ran to the head it read at. The + // `projection_generation` is empty, because no projection instance produced + // this and a synthetic id would be a generation a page cursor could bind to + // that nothing is able to honor later. Which is the constraint that follows: + // a replay answer must not mint a page cursor, so a caller needing to + // paginate through a projection outage has to wait for the projection rather + // than scan against a fallback. + ANSWER_SOURCE_AUTHORITATIVE_REPLAY = 2; +} + +// ProjectionCondition is the projection's state on the success path. +// +// It is deliberately smaller than the set of states a projection can be in. +// Rebuilding, invalid, and missing are failure-path conditions: a projection in +// one of those either serves nothing, in which case the caller gets +// QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE with the matching reason, or serves a +// readable prior generation, in which case it is simply LAGGING. Duplicating +// them here would create two places to express one state and invite them to +// disagree. +enum ProjectionCondition { + PROJECTION_CONDITION_UNSPECIFIED = 0; + // Applied through the observed source head. Nothing known is missing. + PROJECTION_CONDITION_CURRENT = 1; + // Known to be behind the observed source head. + PROJECTION_CONDITION_LAGGING = 2; + // The source head was not observed, so currency could not be determined. + // + // This is not a degraded CURRENT. A caller that needs to know it is reading a + // write it just made must state that with ReadConsistency rather than infer + // it from a condition that says the server did not check. + PROJECTION_CONDITION_INDETERMINATE = 3; +} + +// ConsistencyOutcome reports what the server did about the caller's +// ReadConsistency, so a satisfied requirement is affirmed rather than implied +// by the absence of an error. +message ConsistencyOutcome { + ConsistencyResult result = 1 [features.field_presence = LEGACY_REQUIRED]; + // How long the read waited before answering. Zero for both NOT_REQUESTED and + // SATISFIED_IMMEDIATELY. + uint32 waited_millis = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// ConsistencyResult is how a read's consistency requirement was resolved. +// +// There is no unsatisfied value. A requirement the server could not meet is a +// failure, not a success carrying a flag, because a success shape with an +// ignored flag is exactly what a caller in a hurry will read as an answer. +enum ConsistencyResult { + CONSISTENCY_RESULT_UNSPECIFIED = 0; + // The caller asked for an eventual read. Freshness is still reported. + CONSISTENCY_RESULT_NOT_REQUESTED = 1; + // The projection had already applied the required position. + CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY = 2; + // The read waited for the projection to catch up, then answered. + CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT = 3; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/query_error.proto b/proto/trogonai/session/sessions/queries/v1alpha1/query_error.proto new file mode 100644 index 0000000000..a337f1007b --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/query_error.proto @@ -0,0 +1,169 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/queries/v1alpha1/contract_version.proto"; +import "trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto"; + +// QueryError is the typed failure payload for every Session query. +// +// It is not carried inside a success response. A query either answers or +// fails, and collapsing the two into one message invites a caller to read a +// zero-valued success shape as an empty result. On the JSON-RPC-over-NATS +// binding (ADR#0056) this rides in the error object's `data`; the numeric code +// assignment is a separate reservation and is deliberately not invented here. +// +// `code` is the machine-readable discriminant and the only field a caller +// should branch on. `message` is for humans and may change at any time without +// a version bump, so treating it as an API is a bug. +message QueryError { + QueryErrorCode code = 1 [features.field_presence = LEGACY_REQUIRED]; + // Human-readable, non-contractual, safe to log. Never parse it. + string message = 2 [features.field_presence = LEGACY_REQUIRED]; + // Machine-readable specifics for the codes that have them. A caller must + // tolerate an unset detail: a code may gain one additively, and an older + // caller will not decode a variant added after its minor. + oneof detail { + UnsupportedContractVersionDetail unsupported_contract_version = 3; + StaleCursorDetail stale_cursor = 4; + ProjectionUnavailableDetail projection_unavailable = 5; + InvalidArgumentDetail invalid_argument = 6; + } +} + +// QueryErrorCode is the closed set of reasons a Session query fails. +// +// A caller that receives an unknown value here has reached a server newer than +// its contract minor and must treat it as a non-retryable failure, not as +// success and not as an unconditional retry. +enum QueryErrorCode { + QUERY_ERROR_CODE_UNSPECIFIED = 0; + // The session id resolves to no stream. Distinct from an existing session the + // caller may not see, which is QUERY_ERROR_CODE_PERMISSION_DENIED, so that + // probing cannot use the difference to prove existence. + QUERY_ERROR_CODE_SESSION_NOT_FOUND = 1; + // The caller's declared major is one this server cannot render. Fail closed: + // answering in an unreadable shape is worse than not answering. + QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION = 2; + // The request is malformed: an unparsable id, a page size out of range, a + // filter combination with no meaning. + QUERY_ERROR_CODE_INVALID_ARGUMENT = 3; + // The page token was minted by this contract but no longer names a valid + // position. See CursorValidity for what a cursor binds to and + // StaleCursorReason for which binding broke. Restarting the scan is the fix. + QUERY_ERROR_CODE_STALE_CURSOR = 4; + // The page token was not minted by this contract, is corrupt, fails its MAC, + // or does not match the request it was presented with. Distinct from stale: + // stale means it was valid and the view moved, so a caller can restart the + // scan; malformed means the caller sent something this server never issued + // for this request, and retrying will not help. + QUERY_ERROR_CODE_MALFORMED_CURSOR = 5; + // The backing projection cannot serve the read as asked. Also how an + // unsatisfiable ReadConsistency is reported: a requirement the server could + // not meet is a failure, not a success carrying a flag. + QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE = 6; + // The caller is not authorized for this session. Returned in place of + // NOT_FOUND when disclosing the difference would leak existence. + QUERY_ERROR_CODE_PERMISSION_DENIED = 7; + // The request is valid but too expensive to serve as asked, for example a + // page size above the configured admission limit. + QUERY_ERROR_CODE_RESOURCE_EXHAUSTED = 8; + // An unexpected server-side failure. Carries no detail on purpose. + QUERY_ERROR_CODE_INTERNAL = 9; +} + +// UnsupportedContractVersionDetail tells the caller what it would have to +// speak, so an incompatibility is actionable rather than merely reported. +message UnsupportedContractVersionDetail { + ContractVersion requested = 1 [features.field_presence = LEGACY_REQUIRED]; + // Inclusive range of majors this server can render. + uint32 supported_major_min = 2 [features.field_presence = LEGACY_REQUIRED]; + uint32 supported_major_max = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// StaleCursorDetail says why a previously valid cursor stopped being valid, so +// a caller can tell a benign restart from a view that changed underneath it. +message StaleCursorDetail { + StaleCursorReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; +} + +// StaleCursorReason is what invalidated a cursor. +enum StaleCursorReason { + STALE_CURSOR_REASON_UNSPECIFIED = 0; + // A rewind moved the effective history boundary the cursor was anchored to. + STALE_CURSOR_REASON_REWOUND = 1; + // A redaction or artifact erasure changed the prefix the cursor covered. + STALE_CURSOR_REASON_PRIVACY_CHANGED = 2; + // The projection the cursor was minted against was replaced or rebuilt. + STALE_CURSOR_REASON_PROJECTION_REPLACED = 3; + // The cursor was minted under a contract version this server no longer + // renders. + STALE_CURSOR_REASON_CONTRACT_CHANGED = 4; + // The cursor outlived the window a pinned scan is held open for. Nothing + // about the session changed; the scan simply took too long. + STALE_CURSOR_REASON_EXPIRED = 5; + // A compaction replaced a span the cursor was scanning. Reported separately + // from REWOUND because nothing was retracted: the same history is still + // there, summarized, and a caller may reasonably restart without treating it + // as loss. + STALE_CURSOR_REASON_COMPACTED = 6; +} + +// ProjectionUnavailableDetail distinguishes "come back shortly" from "this is +// broken", which a caller cannot guess from the code alone. +message ProjectionUnavailableDetail { + ProjectionUnavailableReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; + // How current the projection was when it gave up. Present for REASON_LAGGING, + // where it is the difference between an actionable failure and a bare one: a + // caller that can see it reached the required position minus two can retry + // with a larger budget, while one that cannot see it can only guess. + ProjectionFreshness freshness = 2; + // How far along the rebuild is. Present for REASON_REBUILDING when the + // rebuilder can report it. + // + // Without this, "come back shortly" is a claim with no number attached, and a + // caller has to choose between polling a rebuild that will take four hours + // and giving up on one that will take four seconds. Absent means the + // rebuilder could not say, which is different from a rebuild that has made no + // progress. + RebuildProgress rebuild = 3; +} + +// RebuildProgress is how far a projection rebuild has got. +message RebuildProgress { + google.protobuf.Timestamp started_at = 1 [features.field_presence = LEGACY_REQUIRED]; + // Position the rebuild has applied through, in the same units the finished + // projection will report as its processed watermark. + uint64 processed_watermark = 2 [features.field_presence = LEGACY_REQUIRED]; + // Position the rebuild is working toward, as known when it started. + // + // Unset when the rebuilder does not know its own end, which is the honest + // answer for a rebuild over a stream that is still being written to. Reported + // as unset rather than as the current head, because a target that moves is a + // percentage that goes backwards. + uint64 target_watermark = 3; +} + +// ProjectionUnavailableReason is why the read could not be served. +enum ProjectionUnavailableReason { + PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED = 0; + // A rebuild is in progress and no prior generation is readable; the read is + // expected to succeed later. A rebuild that keeps the prior generation + // readable is not this: it answers, with PROJECTION_CONDITION_LAGGING. + PROJECTION_UNAVAILABLE_REASON_REBUILDING = 1; + // The projection is present but failed its own validity checks. + PROJECTION_UNAVAILABLE_REASON_INVALID = 2; + // No projection exists for this scope yet. + PROJECTION_UNAVAILABLE_REASON_MISSING = 3; + // The projection is too far behind to satisfy the requested consistency. + PROJECTION_UNAVAILABLE_REASON_LAGGING = 4; +} + +// InvalidArgumentDetail names the offending input. It carries a field path +// rather than a rendered sentence so a caller can map the failure back to its +// own request structure. +message InvalidArgumentDetail { + // Dotted path into the request message, for example `page_size`. + string field_path = 1 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/read_consistency.proto b/proto/trogonai/session/sessions/queries/v1alpha1/read_consistency.proto new file mode 100644 index 0000000000..75e727d999 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/read_consistency.proto @@ -0,0 +1,72 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "google/protobuf/duration.proto"; + +// ReadConsistency is the freshness the caller requires, declared before the +// server answers. +// +// The case it exists for is read-your-writes. A caller that has just issued a +// command knows the position its write landed at, and an eventual read of a +// projection that has not applied it yet returns a view that is correct and +// wrong at the same time: correct as of the projection, wrong as of what the +// caller knows to have happened. Redaction is the sharp version, since the view +// still contains content the caller was told is gone. +// +// Every request carries one. Unset is EVENTUAL, which keeps the common read +// cheap while still reporting freshness on the way back. +message ReadConsistency { + ReadConsistencyMode mode = 1 [features.field_presence = LEGACY_REQUIRED]; + // Required for MODE_AT_LEAST, ignored otherwise. A MODE_AT_LEAST request with + // no token is QUERY_ERROR_CODE_INVALID_ARGUMENT rather than a silent + // downgrade to an eventual read. + ConsistencyToken token = 2; + // How long the read may wait for the projection to reach the token. Unset or + // zero means do not wait: answer if the projection is already there, fail + // otherwise. + // + // The budget is the caller's because only the caller knows whether it is + // serving an interactive request. A read that cannot be satisfied within it + // fails with QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE and + // PROJECTION_UNAVAILABLE_REASON_LAGGING, carrying the freshness it reached so + // the caller can retry with a larger budget or fall back to an eventual read + // on purpose. + google.protobuf.Duration max_wait = 3; +} + +// ReadConsistencyMode is how strictly the read is bound to a known write. +enum ReadConsistencyMode { + // Treated as EVENTUAL. Unset is the ordinary case, not an error, because + // most reads have no write to be consistent with. + READ_CONSISTENCY_MODE_UNSPECIFIED = 0; + // Serve whatever the projection has applied. Freshness is still reported. + READ_CONSISTENCY_MODE_EVENTUAL = 1; + // Serve only once the projection has applied `token`. + READ_CONSISTENCY_MODE_AT_LEAST = 2; +} + +// ConsistencyToken names a write the read must reflect. +// +// Unlike a page cursor this is a plain typed message, not opaque authenticated +// bytes, and the difference is deliberate. A cursor names a scan position and +// is therefore an instruction the server follows, so a forged one is a way to +// read what the caller should not. A token only ever makes a read wait or fail: +// the worst a forged one achieves is the caller's own bounded wait followed by +// a LAGGING error, and it discloses nothing. Paying for a MAC to prevent that +// would buy nothing and cost every caller the ability to debug its own reads. +// +// The write path mints these. The command-response shape that hands one back is +// not defined yet. +message ConsistencyToken { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The SessionOrdinal the caller's write landed at. + // + // An ordinal rather than a stream sequence, for the same reason page cursors + // use one: it is fold-derived and reproduces identically on replay, so it + // survives a projection rebuild. A list read uses this too, since a list + // projection that consumes many streams still knows how far it has applied + // each one, and "the list reflects my change to session X" is the only + // freshness question a caller actually has. + uint64 session_ordinal = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/queries/v1alpha1/session_view.proto b/proto/trogonai/session/sessions/queries/v1alpha1/session_view.proto new file mode 100644 index 0000000000..3bbcc77113 --- /dev/null +++ b/proto/trogonai/session/sessions/queries/v1alpha1/session_view.proto @@ -0,0 +1,289 @@ +edition = "2024"; + +package trogonai.session.sessions.queries.v1alpha1; + +import "google/protobuf/timestamp.proto"; + +// Read-model value types for the Session query contract. +// +// These are redefined here rather than imported from the write side on purpose +// (ADR#0035 facet 3). The write-side event and state types change whenever the +// domain changes; a public read contract must be able to hold still across +// those changes, and a shared type would forward every write-side edit straight +// to every client. +// +// Every identifier here is opaque. A caller may compare ids for equality and +// pass them back, and must not parse structure out of them. + +// SessionLifecycle is the coarse lifecycle state a reader sees. +// +// It is deliberately coarser than the write side's terminal markers: a reader +// needs to know whether a session is still going, not which command sealed it. +// The specific marker is available on `terminal_reason`. +enum SessionLifecycle { + SESSION_LIFECYCLE_UNSPECIFIED = 0; + SESSION_LIFECYCLE_ACTIVE = 1; + SESSION_LIFECYCLE_TERMINAL = 2; +} + +// TerminalReason is why a session ended, set only for a terminal session. +enum TerminalReason { + TERMINAL_REASON_UNSPECIFIED = 0; + TERMINAL_REASON_CLOSED = 1; + TERMINAL_REASON_CANCELLED = 2; + TERMINAL_REASON_FAILED = 3; + TERMINAL_REASON_HIDDEN = 4; +} + +// SessionSummary is the list-row shape: enough to render a picker, and no more. +// +// It deliberately excludes anything requiring a per-session fan-out to compute, +// because a list query that costs one read per row stops being a list query. +message SessionSummary { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionLifecycle lifecycle = 2 [features.field_presence = LEGACY_REQUIRED]; + // Unset while the session is active. + TerminalReason terminal_reason = 3; + // Display name, resolved by the precedence on TitleSource. Always set: when + // there is nothing to show it holds a server-chosen fallback rather than an + // empty string, so a picker never has to invent one and two clients never + // invent different ones. + string title = 4 [features.field_presence = LEGACY_REQUIRED]; + TitleSource title_source = 5 [features.field_presence = LEGACY_REQUIRED]; + string workspace_id = 6 [features.field_presence = LEGACY_REQUIRED]; + bool archived = 7 [features.field_presence = LEGACY_REQUIRED]; + // Effective history length in SessionOrdinals, after rewind masking. A caller + // must not treat this as a count of decodable history items: redaction can + // mask an ordinal without removing it. + uint64 effective_length = 8 [features.field_presence = LEGACY_REQUIRED]; + // Set when this session is a copy salvaged from a damaged one. On the list row + // and not only the detail view, because a picker that renders a salvaged + // session identically to an intact one is where the substitution actually + // happens: by the time a user opens it they have already decided it is theirs. + RecoveryProvenanceView recovery = 9; + // Short excerpt of the session's opening content. Always set, including when + // there is nothing to preview, because the reason there is nothing is itself + // what a caller needs in order to render the row honestly. + SessionPreview preview = 10 [features.field_presence = LEGACY_REQUIRED]; +} + +// SessionPreview is the excerpt shown beneath a session's title. +// +// It is derived from effective history, which is what makes it a projection +// concern rather than a stored string. Rewind masks ordinals, redaction removes +// content from ordinals that remain, and either can take away the very message a +// preview was cut from. A preview cached without regard for that is the case +// where deliberately destroyed text reappears on a screen, which is a privacy +// failure and not a staleness annoyance. +// +// Its validity therefore tracks `effective_history_revision` and +// `privacy_revision`, the same two coordinates a presentation cache binds +// against. A cached preview whose binding fails those two must be discarded, not +// shown as merely older. +message SessionPreview { + // The excerpt, truncated at a server-chosen bound. Empty for every + // availability other than SESSION_PREVIEW_AVAILABILITY_AVAILABLE. + string text = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionPreviewAvailability availability = 2 [features.field_presence = LEGACY_REQUIRED]; + // True when the excerpt is shorter than the content it came from, so a + // renderer can mark the cut rather than presenting a fragment as a whole + // message. + bool truncated = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// SessionPreviewAvailability is why a preview is or is not there. +// +// Absence has several causes with different meanings, and collapsing them into +// an empty string tells a user that a session is empty when it may only be one +// they are not cleared to see, or one whose opening message was deliberately +// removed. +enum SessionPreviewAvailability { + SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED = 0; + // An excerpt is present in `text`. + SESSION_PREVIEW_AVAILABILITY_AVAILABLE = 1; + // The session has no effective authored content to preview. + SESSION_PREVIEW_AVAILABILITY_EMPTY = 2; + // Content exists but is not text: an image-only or attachment-only opening. + SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL = 3; + // The content a preview would come from was redacted. Distinguished from empty + // because a session that was emptied on purpose is not a session that was + // never used, and a UI that says "no messages" about a redaction is lying + // about what happened. + SESSION_PREVIEW_AVAILABILITY_REDACTED = 4; + // The content exists and this caller may not see it. Per-caller, like + // ArtifactCompletenessView.hidden: two readers of the same session can get + // different answers, and the difference is authorization rather than content. + SESSION_PREVIEW_AVAILABILITY_WITHHELD = 5; +} + +// RecoveryProvenanceView marks a session that was salvaged rather than lived. +// +// Unset is the ordinary case. When set, a reader must not present the session as +// the source: it has a different id, its ordinals are its own, and a partial +// recovery is missing content the original had. +message RecoveryProvenanceView { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + RecoveryCompletenessView completeness = 2 [features.field_presence = LEGACY_REQUIRED]; + // How many source items the salvage could not carry. The enumeration is an + // operator-side record and is deliberately not on the read contract: a client + // needs to know the session is incomplete, not to render a damage report. + uint32 omitted_count = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// RecoveryCompletenessView is how much of the source a salvaged session carries. +enum RecoveryCompletenessView { + RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED = 0; + RECOVERY_COMPLETENESS_VIEW_COMPLETE = 1; + RECOVERY_COMPLETENESS_VIEW_PARTIAL = 2; +} + +// TitleSource says where a rendered title came from, and by doing so fixes the +// precedence that produced it. +// +// The projection resolves a title in one order, always: the latest effective +// SessionRenamed if one survives, otherwise a title derived from the first +// effective user message, otherwise a fallback. Publishing which rule fired is +// what makes the result checkable, and it lets a client style a guess +// differently from a name a human chose. +// +// The two sources invalidate differently, and that asymmetry is the reason this +// field exists rather than a `title_is_explicit` bool. A derived title is a +// function of effective history, so a rewind past the first user message or a +// redaction of it changes the title. An explicit title is an authoritative fact +// of its own and survives both. What it does not survive is being redacted +// itself, and when that happens the resolution falls back down the same +// precedence rather than keeping a name whose source no longer exists. +enum TitleSource { + TITLE_SOURCE_UNSPECIFIED = 0; + // A human renamed the session, and that rename is still effective. + TITLE_SOURCE_EXPLICIT = 1; + // Derived from the first effective user message. Follows effective history: + // rewinding or redacting that message changes it. + TITLE_SOURCE_DERIVED = 2; + // Nothing to derive from: an empty or image-only session, or one whose + // openings are all masked. The server supplies the string. + TITLE_SOURCE_FALLBACK = 3; +} + +// SessionView is the detail shape returned by GetSession. +// +// It reports lifecycle and shape, never the transcript. History is a separate, +// paginated query because a session's history has no bound and a detail read +// that inlines it has no bound either. +message SessionView { + SessionSummary summary = 1 [features.field_presence = LEGACY_REQUIRED]; + // Set when this session was forked from another. + ForkOriginView fork_origin = 2; + // Set when this session was dispatched by a parent. + ParentView parent = 3; + // Sessions this one dispatched, parent side. + repeated DelegationView delegations = 4; + // True when at least one tool call has started with no terminal outcome, or + // at least one reserved operation is unsettled. This is the reader-visible + // form of "something needs reconciling"; a caller must not conclude a session + // is complete from a terminal lifecycle alone. + bool has_unreconciled_work = 5 [features.field_presence = LEGACY_REQUIRED]; + // How much of this session's artifact content is still retrievable. Always + // set, including when everything is intact, so a caller never has to read an + // absent field as good news. + ArtifactCompletenessView artifacts = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// ArtifactCompletenessView is how complete this session's artifact content is, +// reported separately from its lifecycle. +// +// The two are independent and routinely disagree. A session can close having +// done exactly what was asked and still be missing the output it produced, +// because artifact bytes live outside the log and outlive nothing in +// particular: they get erased under a retention policy, or under a deletion +// request, or by a storage fault. A reader that infers retrievability from +// TERMINAL_REASON_CLOSED will present an empty result as a successful one. +// +// This rollup counts only what the log itself establishes. Whether the bytes an +// intact claim-check points to are actually there is a fact about an external +// store, and learning it costs one probe per artifact, which is not something a +// list or detail query can do and remain a query. That answer arrives through +// `observed` when someone has gone and looked. +message ArtifactCompletenessView { + // Artifacts recorded on this session's effective history. Rewind-masked and + // redacted ordinals contribute nothing, so this counts what the caller can + // see referenced rather than everything ever recorded. + uint32 recorded = 1 [features.field_presence = LEGACY_REQUIRED]; + // Recorded with durably stored bytes and no erasure since. This is the count + // the log supports; it is a claim about what was promised, not about what a + // store would return right now. + uint32 claimed_retrievable = 2 [features.field_presence = LEGACY_REQUIRED]; + // Destroyed on purpose, recorded by ArtifactErased. Counted apart from every + // other absence because it is the one that is working as intended. + uint32 erased = 3 [features.field_presence = LEGACY_REQUIRED]; + // Recorded as an external reference whose bytes were never durably stored. + // Nothing was lost; nothing was ever held. + uint32 external_only = 4 [features.field_presence = LEGACY_REQUIRED]; + // Referenced by this session and not readable by this caller. Per-caller, so + // two readers of the same session can see different totals, and the point of + // surfacing it is that the difference is authorization rather than damage. + uint32 hidden = 5 [features.field_presence = LEGACY_REQUIRED]; + // Set only when the artifact store has actually been checked for this + // session. Unset means nobody has looked, which is not the same as nothing + // being wrong, and the field is absent rather than zeroed so the two cannot + // be confused. + ObservedIntegrityView observed = 6; +} + +// ObservedIntegrityView is what a probe of the artifact store found, and when. +// +// These counts age. They describe a store at the instant it was read, and an +// artifact can be lost the moment after; `observed_at` is here so a caller can +// decide whether the answer is still worth acting on rather than treating a +// stale all-clear as a current one. +message ObservedIntegrityView { + // Claim-checks the store had no object for, with no erasure recorded. This is + // the count that means data was lost. + uint32 missing = 1 [features.field_presence = LEGACY_REQUIRED]; + // Objects present whose content does not match the digest on the log. + uint32 digest_mismatch = 2 [features.field_presence = LEGACY_REQUIRED]; + // Objects that could not be read at all, which makes no claim about whether + // they exist. Counted apart from `missing` because a transport or permissions + // fault reported as data loss sends an operator looking for a backup instead + // of a broken credential. + uint32 unreadable = 3 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp observed_at = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// ForkOriginView names the session this one branched from. +message ForkOriginView { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The source ordinal this session's inherited context ends at. + uint64 context_prefix_boundary = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// ParentView names the session that dispatched this one, and whether that +// lineage still holds. +message ParentView { + string parent_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The parent ended and this session observed it. + bool parent_terminated = 2 [features.field_presence = LEGACY_REQUIRED]; + // The parent rewound past the dispatch: the inherited context no longer + // exists, so this session's history is no longer grounded in the parent's. + bool history_invalidated = 3 [features.field_presence = LEGACY_REQUIRED]; + // The lineage was explicitly released. + bool detached = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// DelegationView is one dispatched child or external delegate. +message DelegationView { + string operation_id = 1 [features.field_presence = LEGACY_REQUIRED]; + DelegationKindView kind = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set for DELEGATION_KIND_VIEW_CHILD_SESSION. + string child_session_id = 3; + // Set for DELEGATION_KIND_VIEW_EXTERNAL. + string delegate_reference = 4; + bool detached = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// DelegationKindView is where delegated work runs. +enum DelegationKindView { + DELEGATION_KIND_VIEW_UNSPECIFIED = 0; + DELEGATION_KIND_VIEW_CHILD_SESSION = 1; + DELEGATION_KIND_VIEW_EXTERNAL = 2; +} diff --git a/proto/trogonai/session/sessions/replay/v1alpha1/frame.proto b/proto/trogonai/session/sessions/replay/v1alpha1/frame.proto new file mode 100644 index 0000000000..195d1f6ddc --- /dev/null +++ b/proto/trogonai/session/sessions/replay/v1alpha1/frame.proto @@ -0,0 +1,57 @@ +edition = "2024"; + +package trogonai.session.sessions.replay.v1alpha1; + +import "google/protobuf/duration.proto"; + +// The byte layout of a command-output replay artifact, format version 1. +// +// An artifact is two regions. The frame region runs from offset 0 and holds +// frames back to back, each one a little-endian uint32 byte length followed by +// that many bytes of a serialized ReplayFrame. The index region is a trailer +// holding a serialized ReplayIndex; its offset and length are recorded on the +// log, in CommandOutputReplayRef. +// +// These types are defined here rather than on the write side because they +// describe bytes a reader parses, not a field an event carries. The write side +// records where the capture is and what it is worth; this is what is inside it, +// and the two change for different reasons (ADR#0035 facet 3). + +// ReplayFrame is one contiguous run of output the capturer read in one go. +// +// A frame boundary is a fact about the capturer's read loop and nothing else. +// It is not a line, not a write() by the process, and not a flush. A renderer +// that treats frames as lines will split a line that arrived in two reads, and +// it will do it differently on a fast machine than a slow one. +message ReplayFrame { + // The capturer's own count, starting at 0, never compacted. + // + // When frames are dropped the surviving ones keep the numbers they were + // given, so a gap in this sequence is a gap in the output. Renumbering to + // stay contiguous would erase the only evidence inside the artifact that + // anything is missing. + uint64 sequence = 1 [features.field_presence = LEGACY_REQUIRED]; + ReplayStream stream = 2 [features.field_presence = LEGACY_REQUIRED]; + // Raw bytes as captured. Not decoded, not normalized, and specifically not + // stripped of control sequences: a terminal replay that removes them is + // replaying something the terminal never showed. Decoding is the renderer's + // job and is a decision it gets to make at render time, more than once. + bytes payload = 3; + // Elapsed time from the start of capture to when the capturer observed this + // frame. Present only when CommandOutputReplayRef.timing is + // TIMING_FIDELITY_CAPTURE_ELAPSED, and unset on every frame otherwise. + google.protobuf.Duration elapsed = 4; +} + +// ReplayStream is which stream a frame came from. +enum ReplayStream { + REPLAY_STREAM_UNSPECIFIED = 0; + REPLAY_STREAM_STDOUT = 1; + REPLAY_STREAM_STDERR = 2; + // Captured through one terminal or one pipe, where the two streams were + // already indistinguishable before the capturer saw them. Every frame of a + // CAPTURE_MODE_MERGED_TERMINAL artifact carries this. It means attribution is + // unavailable, not that it is pending, and a renderer must not infer stderr + // from content to fill it in. + REPLAY_STREAM_MERGED = 3; +} diff --git a/proto/trogonai/session/sessions/replay/v1alpha1/index.proto b/proto/trogonai/session/sessions/replay/v1alpha1/index.proto new file mode 100644 index 0000000000..875cce6988 --- /dev/null +++ b/proto/trogonai/session/sessions/replay/v1alpha1/index.proto @@ -0,0 +1,60 @@ +edition = "2024"; + +package trogonai.session.sessions.replay.v1alpha1; + +import "google/protobuf/duration.proto"; + +// ReplayIndex is the trailer that makes a bounded range read of a replay +// artifact useful. +// +// Range reads are byte-granular and frames are variable-length, so a read into +// the middle of the frame region lands mid-frame, with no way to tell from the +// bytes where the next boundary is. Without an index the only correct way to +// reach frame one million is to parse the previous 999,999, which is exactly +// the cost that keeping the output out of the log was supposed to avoid. +// +// The index is sparse. It marks frame boundaries at intervals rather than every +// frame, because an entry per frame is an index whose size grows with the +// output it indexes, which is the problem again with more steps. A reader seeks +// to the nearest preceding entry and scans forward a bounded distance. +message ReplayIndex { + // Total frames in the capture, and total payload bytes across them. + // + // Both are also on the log, in CommandOutputReplayRef. The repetition is the + // point: a reader that has fetched only this trailer can check it against the + // event before trusting a single offset in it, and the event is the copy the + // artifact store did not supply. An index that disagrees with the log is not + // a stale index, it is the wrong artifact or a damaged one. + uint64 frame_count = 1 [features.field_presence = LEGACY_REQUIRED]; + uint64 output_byte_count = 2 [features.field_presence = LEGACY_REQUIRED]; + // Seek points in artifact order, always including a first entry at frame 0. + // + // The stride is the capturer's choice and is not recorded, because a reader + // has no use for it: it binary-searches on whichever coordinate it is seeking + // by, and a fixed stride would be a promise a capturer that stops early + // cannot keep. + repeated ReplayIndexEntry entries = 3; +} + +// ReplayIndexEntry is one seek point, expressed in every coordinate a reader +// might be seeking by. +// +// The three offsets are not redundant. They answer different questions, and a +// reader converting between them would have to parse the frames to do it, which +// is what it came here to avoid. +message ReplayIndexEntry { + // Byte offset of a frame boundary, from the start of the artifact. This is + // the value a range read takes. + uint64 byte_offset = 1 [features.field_presence = LEGACY_REQUIRED]; + // Sequence of the frame at that boundary. Not the entry's position times a + // stride: dropped frames leave gaps in the sequence, so this has to be + // recorded. + uint64 frame_sequence = 2 [features.field_presence = LEGACY_REQUIRED]; + // Payload bytes emitted before that frame. This is what a UI scrolls and + // measures in, since a user positions themselves in output, not in framing + // overhead. + uint64 output_byte_offset = 3 [features.field_presence = LEGACY_REQUIRED]; + // Elapsed time at that frame. Present only when the capture recorded timing, + // and it is what makes seeking by time possible without reading anything. + google.protobuf.Duration elapsed = 4; +} diff --git a/proto/trogonai/session/sessions/state/v1alpha1/state.proto b/proto/trogonai/session/sessions/state/v1alpha1/state.proto new file mode 100644 index 0000000000..4e61315aec --- /dev/null +++ b/proto/trogonai/session/sessions/state/v1alpha1/state.proto @@ -0,0 +1,227 @@ +edition = "2024"; + +package trogonai.session.sessions.state.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/cascade_policy.proto"; +import "trogonai/session/sessions/v1alpha1/checkpoint.proto"; +import "trogonai/session/sessions/v1alpha1/digest.proto"; +import "trogonai/session/sessions/v1alpha1/operation_reserved.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/session_recovered.proto"; + +// State is the Session aggregate's write-side fold: exactly the facts the +// session commands read to enforce their invariants, and nothing a read model +// owns (ADR#0035, ADR#0045). It is never a projection and never a transcript; +// message bodies, todo items, artifacts, and display metadata are deliberately +// absent because no command reads them. +// +// A crash between a started tool call and its outcome is the load-bearing case: +// replaying a session leaves that call in TOOL_CALL_STATUS_STARTED with no +// settled_at, and its reserved operation in OPERATION_STATUS_RESERVED, so +// reconciliation can see the missing terminal outcome and finish or reject the +// interrupted call rather than silently dropping it. +message State { + StateValue state = 1 [features.field_presence = LEGACY_REQUIRED]; + string session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Count of events folded so far: this session's own fold-derived ordinal of + // the last applied event, never a JetStream sequence (ADR#0013). + trogonai.session.sessions.v1alpha1.SessionOrdinal position = 3 [features.field_presence = LEGACY_REQUIRED]; + // Digest of the immutable StoredSessionExecutionPlan recorded at start; every + // attempt, checkpoint, and compaction is bound to it. + trogonai.session.sessions.v1alpha1.Digest execution_plan_digest = 4; + // Which marker sealed the session. The first terminal marker wins; a later one + // is audit-only. + TerminalMarker terminal_marker = 5 [features.field_presence = LEGACY_REQUIRED]; + // Context root when this session was forked from another one; unset for a + // session that started its own context. + ForkOrigin fork_origin = 6; + // Provenance of a salvaged session; unset for a session that was not + // recovered from a damaged source. Folded because it is a precondition the + // commands must be able to read: a session that is a partial copy cannot + // honor a rewind or a compaction against source positions it never received. + RecoveryOrigin recovery_origin = 19; + // Recorded parent lineage of a delegated child session. + ParentLink parent = 7; + // Newest rewind boundary. Rewind masks effective history for readers and + // future turns; it never un-applies folded facts, because a tool call that + // really ran still has to be reconcilable. + trogonai.session.sessions.v1alpha1.SessionOrdinal keep_through = 8; + // Newest compaction marker, the prior usable boundary a further compaction + // and an attempt restore both resolve against. + CompactionMarker compaction = 9; + // Attempt currently holding the session; unset when no attempt is running. + ExecutionAttempt active_attempt = 10; + // Most recently started attempt, still active or already ended, so a new + // attempt can be checked for monotonic numbering and exact predecessor. + string last_attempt_id = 11; + uint64 last_attempt_number = 12; + // Tool calls keyed by tool_call_id, in first-observed fold order. + repeated ToolCall tool_calls = 13; + // Operation ledger entries keyed by operation_id, in reservation fold order. + repeated Operation operations = 14; + // Dispatched delegations keyed by operation_id, parent side. + repeated Delegation delegations = 15; + // First admitted evidence per checkpoint_id; a later event reusing an id is + // retained on the log but never replaces the admitted evidence. + repeated CheckpointEvidence checkpoints = 16; + // Privacy dependencies an attempt restore and a compaction must respect. + repeated string redacted_event_ids = 17; + repeated string erased_artifact_ids = 18; +} + +enum StateValue { + STATE_VALUE_UNSPECIFIED = 0; + // No SessionStarted folded: the stream does not exist yet. + STATE_VALUE_MISSING = 1; + STATE_VALUE_ACTIVE = 2; + // Sealed by a terminal marker: no further invariant-bearing transition is + // admitted, though guarded ledger and lineage facts still fold so an + // in-flight side effect stays reconcilable. + STATE_VALUE_TERMINAL = 3; +} + +enum TerminalMarker { + TERMINAL_MARKER_UNSPECIFIED = 0; + TERMINAL_MARKER_CLOSED = 1; + TERMINAL_MARKER_CANCELLED = 2; + TERMINAL_MARKER_FAILED = 3; + TERMINAL_MARKER_HIDDEN = 4; +} + +message ForkOrigin { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal context_prefix_boundary = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// RecoveryOrigin is the damaged source a salvaged session was copied from. +// +// source_boundary is a position on the source's stream, not on this one. This +// session's ordinals count its own events and start at 1 regardless of where the +// source's cut ended. +message RecoveryOrigin { + string source_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal source_boundary = 2 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.Digest source_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + string salvage_key = 4 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.RecoveryCompleteness completeness = 5 [features.field_presence = LEGACY_REQUIRED]; + uint32 omitted_count = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +message ParentLink { + string parent_session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The parent's own ordinal of the dispatch that created this session. + trogonai.session.sessions.v1alpha1.SessionOrdinal parent_dispatched_at = 2 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.CascadePolicy cascade_policy = 3 [features.field_presence = LEGACY_REQUIRED]; + // The parent-side operation this session was dispatched under. + string operation_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // The parent reached a terminal state and this session observed it. + bool parent_terminated = 5 [features.field_presence = LEGACY_REQUIRED]; + // The parent rewound past the dispatch: the inherited prefix no longer holds. + bool history_invalidated = 6 [features.field_presence = LEGACY_REQUIRED]; + // Set once the lineage is detached, making the detach idempotent per id. + string detach_operation_id = 7; +} + +message Delegation { + string operation_id = 1 [features.field_presence = LEGACY_REQUIRED]; + DelegationKind kind = 2 [features.field_presence = LEGACY_REQUIRED]; + // Set for DELEGATION_KIND_CHILD_SESSION. + string child_session_id = 3; + trogonai.session.sessions.v1alpha1.CascadePolicy cascade_policy = 4; + // Set for DELEGATION_KIND_EXTERNAL. + string delegate_reference = 5; + trogonai.session.sessions.v1alpha1.SessionOrdinal dispatched_at = 6 [features.field_presence = LEGACY_REQUIRED]; + // Set once the child is detached, making the detach idempotent per id. + string detach_operation_id = 7; +} + +enum DelegationKind { + DELEGATION_KIND_UNSPECIFIED = 0; + DELEGATION_KIND_CHILD_SESSION = 1; + DELEGATION_KIND_EXTERNAL = 2; +} + +message ExecutionAttempt { + string execution_attempt_id = 1 [features.field_presence = LEGACY_REQUIRED]; + uint64 attempt_number = 2 [features.field_presence = LEGACY_REQUIRED]; + // The attempt published its ready attestation; until then it holds the + // session but must not be treated as serving. + bool ready = 3 [features.field_presence = LEGACY_REQUIRED]; + // Checkpoint the attempt restored from, empty when it started from scratch. + string restored_checkpoint_id = 4; + // Ordinal of the ExecutionAttemptStarted event itself: the head the attempt + // selected, and the point its tail replay resumes from. + trogonai.session.sessions.v1alpha1.SessionOrdinal started_at = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +message CompactionMarker { + string summary_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Ordinal of the Compacted event itself. + trogonai.session.sessions.v1alpha1.SessionOrdinal marker_ordinal = 2 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal covers_from = 3 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal covers_through = 4 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.Digest covered_input_digest = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +message ToolCall { + string tool_call_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Retry identity of the call, and the key its terminal outcome joins on. + string tool_execution_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_name = 3 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // The operation ledger entry guarding this call's side effect, when it + // reserves one. + string operation_id = 5; + ToolCallStatus status = 6 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal requested_at = 7 [features.field_presence = LEGACY_REQUIRED]; + // Set when the call started executing. A call with started_at set and + // settled_at unset is exactly an interrupted call awaiting reconciliation. + trogonai.session.sessions.v1alpha1.SessionOrdinal started_at = 8; + // Set by the first terminal outcome; a later conflicting one is audit-only. + trogonai.session.sessions.v1alpha1.SessionOrdinal settled_at = 9; +} + +enum ToolCallStatus { + TOOL_CALL_STATUS_UNSPECIFIED = 0; + TOOL_CALL_STATUS_REQUESTED = 1; + TOOL_CALL_STATUS_APPROVED = 2; + // Terminal: the call was refused and never ran. + TOOL_CALL_STATUS_DENIED = 3; + TOOL_CALL_STATUS_STARTED = 4; + TOOL_CALL_STATUS_COMPLETED = 5; + TOOL_CALL_STATUS_FAILED = 6; +} + +message Operation { + string operation_id = 1 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.OperationKind operation_kind = 2 [features.field_presence = LEGACY_REQUIRED]; + // Digest of the reserved request, so a retry carrying different bytes under + // the same id is refused instead of executed twice. + trogonai.session.sessions.v1alpha1.Digest request_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + OperationStatus status = 4 [features.field_presence = LEGACY_REQUIRED]; + // Cancellation was asked for; it does not settle the operation, which still + // needs a recorded outcome. + bool cancellation_requested = 5 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.SessionOrdinal reserved_at = 6 [features.field_presence = LEGACY_REQUIRED]; + // Set by the determinate outcome that settled the operation. + trogonai.session.sessions.v1alpha1.SessionOrdinal settled_at = 7; +} + +enum OperationStatus { + OPERATION_STATUS_UNSPECIFIED = 0; + // Reserved, no outcome recorded: the side effect may or may not have run. + OPERATION_STATUS_RESERVED = 1; + // Recorded as indeterminate. Non-terminal, and supersedable exactly once by + // a determinate outcome. + OPERATION_STATUS_UNKNOWN = 2; + OPERATION_STATUS_SUCCEEDED = 3; + OPERATION_STATUS_FAILED = 4; + OPERATION_STATUS_CANCELLED = 5; +} + +message CheckpointEvidence { + string checkpoint_id = 1 [features.field_presence = LEGACY_REQUIRED]; + trogonai.session.sessions.v1alpha1.Checkpoint checkpoint = 2 [features.field_presence = LEGACY_REQUIRED]; + // Ordinal of the CheckpointProduced event that admitted this evidence. + trogonai.session.sessions.v1alpha1.SessionOrdinal produced_at = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/apply_redaction.proto b/proto/trogonai/session/sessions/v1alpha1/apply_redaction.proto new file mode 100644 index 0000000000..3a57041146 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/apply_redaction.proto @@ -0,0 +1,17 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// ApplyRedaction marks recorded events as redacted, recording +// [RedactionApplied]. Redaction is a recorded fact about history, not a +// rewrite of it (ADR#0035 facet 5). +// +// Write precondition At. The invariant that the targeted ids exist in this +// session cannot be checked from folded state today: no event carries its own +// envelope id into evolve, which ADR#0035 lists as an unmet substrate +// obligation. +message ApplyRedaction { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + repeated string redacted_event_ids = 2; + string reason = 3; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/approve_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/approve_tool_call.proto new file mode 100644 index 0000000000..204b8f5201 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/approve_tool_call.proto @@ -0,0 +1,17 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// ApproveToolCall records a human decision to allow a call, recording +// [ToolCallApproved]. +// +// Write precondition At: approve and deny are mutually exclusive, so a decision +// taken against a stale head must be rejected rather than appended beside its +// opposite. +message ApproveToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string approved_by = 4 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 5; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/archive_session.proto b/proto/trogonai/session/sessions/v1alpha1/archive_session.proto new file mode 100644 index 0000000000..8e1e4b4da1 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/archive_session.proto @@ -0,0 +1,12 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// ArchiveSession moves a session out of the default listing view, recording +// [SessionArchived]. Reversible organization state, unlike the terminal +// HideSession. +// +// Write precondition Any. +message ArchiveSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/artifact.proto b/proto/trogonai/session/sessions/v1alpha1/artifact.proto index 4362e0a9da..ea5a00937c 100644 --- a/proto/trogonai/session/sessions/v1alpha1/artifact.proto +++ b/proto/trogonai/session/sessions/v1alpha1/artifact.proto @@ -3,6 +3,7 @@ edition = "2024"; package trogonai.session.sessions.v1alpha1; import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/v1alpha1/content_chunks.proto"; import "trogonai/session/sessions/v1alpha1/digest.proto"; // ArtifactRef is an inline claim-check to an artifact stored out of line: the @@ -69,6 +70,10 @@ message StoredArtifact { string storage_ref = 3 [features.field_presence = LEGACY_REQUIRED]; // Decoded/validated media type of the stored bytes. string mime = 4 [features.field_presence = LEGACY_REQUIRED]; + // Chunk hashing that lets a caller check part of this artifact without + // reading all of it. Unset when the artifact was stored without one, which + // means no range of it can be checked. + ContentChunks chunks = 5; } // ExternalArtifact is the degraded source arm for an artifact whose bytes were diff --git a/proto/trogonai/session/sessions/v1alpha1/cancel_session.proto b/proto/trogonai/session/sessions/v1alpha1/cancel_session.proto new file mode 100644 index 0000000000..b3d9c65fdb --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/cancel_session.proto @@ -0,0 +1,14 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_cancelled.proto"; + +// CancelSession seals a session as cancelled, recording [SessionCancelled]. +// +// Write precondition At: rejected if the session is already terminal. +message CancelSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionCancellationReason reason = 2 [features.field_presence = LEGACY_REQUIRED]; + string detail = 3; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/close_session.proto b/proto/trogonai/session/sessions/v1alpha1/close_session.proto new file mode 100644 index 0000000000..ebc1cf4651 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/close_session.proto @@ -0,0 +1,15 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; + +// CloseSession seals a session as completed, recording [SessionClosed]. +// +// Write precondition At: the first terminal marker is authoritative, so a +// decision taken against a stale head must be rejected rather than appended. +message CloseSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Out-of-line result of the session's work, when it produced one. + ArtifactRef result_ref = 2; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/command_output_replay.proto b/proto/trogonai/session/sessions/v1alpha1/command_output_replay.proto new file mode 100644 index 0000000000..a36b30ddbc --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/command_output_replay.proto @@ -0,0 +1,142 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; + +// CommandOutputReplayRef is a claim-check to the captured output of a +// process-executing tool call, plus the small set of facts a reader needs +// before it is allowed to render any of it. +// +// The output itself is an artifact: one immutable, content-addressed blob of +// framed stdout and stderr, referenced from the terminal event rather than +// appended to the log as an event per chunk. A long command emits millions of +// writes, and a log that records them is a log whose size is set by the noisiest +// thing that ever ran on it, permanently, because nothing ever leaves the log +// (ADR#0035 facet 7). +// +// It lives on ToolCallCompleted, next to CommandTermination and for the same +// reason (D11): it is the execution and audit record, not the transcript the +// model received. The model saw ToolCallResult, which is usually a truncation +// or a summary. Putting raw captured output into the replay shape would feed a +// later turn context the original turn never had. +// +// Every field here is on the log rather than only inside the artifact, because +// the artifact's bytes may be erased (ArtifactErased) while the log keeps its +// provenance. After erasure a reader can still say the command produced 2.1 +// million frames and 40 MB and was captured through a terminal, which is the +// point of separating byte lifecycle from log retention. +message CommandOutputReplayRef { + // Claim-check to the framed capture. Its `preview` conventionally holds the + // tail of the output, which is the part someone reading a command log wants + // first. + ArtifactRef artifact = 1 [features.field_presence = LEGACY_REQUIRED]; + // Version of the byte layout inside the artifact, as defined by + // trogonai.session.sessions.replay.v1alpha1. + // + // Carried as a number and not read out of the artifact's media type, because + // a reader deciding whether it can parse these frames should not be doing + // string surgery on a MIME parameter to find out. + uint32 format_version = 2 [features.field_presence = LEGACY_REQUIRED]; + CaptureMode capture_mode = 3 [features.field_presence = LEGACY_REQUIRED]; + TimingFidelity timing = 4 [features.field_presence = LEGACY_REQUIRED]; + ReplayCompleteness completeness = 5 [features.field_presence = LEGACY_REQUIRED]; + // Frames in the capture. + uint64 frame_count = 6 [features.field_presence = LEGACY_REQUIRED]; + // Payload bytes across all frames, which is the size of the output as a user + // understands it. Always smaller than ArtifactRef.size_bytes, which includes + // framing overhead and the index. + uint64 output_byte_count = 7 [features.field_presence = LEGACY_REQUIRED]; + // Where the seek index sits inside the artifact. + // + // The index is a trailer, because a capturer streaming a running process does + // not know it until the process exits and so cannot write it as a header. Its + // location is recorded here so a reader can range-read the index directly, + // rather than seeking relative to an end-of-object the artifact store might + // report differently than the log does. + uint64 index_offset = 8 [features.field_presence = LEGACY_REQUIRED]; + uint64 index_length = 9 [features.field_presence = LEGACY_REQUIRED]; +} + +// CaptureMode is how the output was collected, which decides what the frame +// order and the per-frame stream tag are actually worth. +// +// A renderer that ignores this will misrepresent output in one of two +// directions, and which one depends on a decision made at spawn time that it +// cannot see. +enum CaptureMode { + CAPTURE_MODE_UNSPECIFIED = 0; + // stdout and stderr were read from separate pipes. + // + // Stream attribution is exact and the interleaving is not: the child's own + // buffering decides when each pipe becomes readable, so a line written to + // stderr before a line written to stdout can be captured after it. A renderer + // may color the two streams and must not present their relative order as the + // order the process produced them in. + CAPTURE_MODE_SEPARATE_PIPES = 1; + // Both streams were written to one terminal or one pipe. + // + // The interleaving is the process's own and is exact. Stream attribution is + // gone: the frames say MERGED because at capture time there was nothing left + // to distinguish. A renderer must not guess stderr from content, which is + // what makes this the honest opposite of SEPARATE_PIPES rather than a + // strictly worse version of it. + CAPTURE_MODE_MERGED_TERMINAL = 2; +} + +// TimingFidelity is whether the capture can be played back at speed, or only in +// order. +// +// Order-only is the common case and the safe default, and it is stated rather +// than left to inference because a replay UI that animates untimed frames is +// inventing pacing and presenting it as a recording. +enum TimingFidelity { + TIMING_FIDELITY_UNSPECIFIED = 0; + // Frames carry no timing. Only their sequence is meaningful. + TIMING_FIDELITY_ORDER_ONLY = 1; + // Frames carry the elapsed time at which the capturer observed them, which is + // not when the process wrote them: pipe buffering, scheduler delay, and the + // capturer's own read loop all sit in between. Close enough to replay at + // speed, not evidence of when anything happened. + TIMING_FIDELITY_CAPTURE_ELAPSED = 2; +} + +// ReplayCompleteness is how much of the output survived capture. +// +// This is not ArtifactRef.truncated, which says a preview is shorter than its +// content. This says the content is shorter than what the process emitted, and +// names which end went missing, because for a command log that is the whole +// question: losing the tail loses the failure, losing the head loses what was +// run. +message ReplayCompleteness { + // Unspecified is not complete. A reader that cannot recognize the shape must + // treat the capture as of unknown completeness rather than whole. + TruncationShape shape = 1 [features.field_presence = LEGACY_REQUIRED]; + // Payload bytes the capturer saw and did not retain. + // + // Unset means dropping occurred and was not counted, which a fixed-size ring + // buffer that overwrites without accounting cannot avoid. Left absent rather + // than reported as zero, because zero here would say nothing was lost. + uint64 dropped_byte_count = 2; + // Frames the capturer saw and did not retain, under the same rule. + uint64 dropped_frame_count = 3; +} + +// TruncationShape is which part of the output is missing. +enum TruncationShape { + TRUNCATION_SHAPE_UNSPECIFIED = 0; + // Everything the process emitted was captured. + TRUNCATION_SHAPE_COMPLETE = 1; + // The beginning was dropped, typically by a ring buffer that kept the most + // recent output. The command's own startup and its invocation echo are gone. + TRUNCATION_SHAPE_HEAD_DROPPED = 2; + // Capture stopped at a cap and the rest was discarded. Whatever the command + // said on its way out, including why it failed, is not here. + TRUNCATION_SHAPE_TAIL_DROPPED = 3; + // The head and the tail were kept and a span in the middle was not. Frame + // sequence numbers are the capturer's original count and are never compacted + // when frames are dropped, so the gap is visible in the frames themselves; + // this value is what lets a reader know to expect one without scanning for + // it. + TRUNCATION_SHAPE_MIDDLE_DROPPED = 4; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/compact_session.proto b/proto/trogonai/session/sessions/v1alpha1/compact_session.proto new file mode 100644 index 0000000000..3f651a6f30 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/compact_session.proto @@ -0,0 +1,36 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/compacted.proto"; +import "trogonai/session/sessions/v1alpha1/digest.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/token_usage.proto"; + +// CompactSession replaces a covered span of history with a summary, recording +// [Compacted]. The command carries the summary its producer generated; the +// aggregate decides whether that cut is admissible. +// +// Write precondition At. The heaviest invariant set in the aggregate: the cut +// must start at the context root, land between complete turn groups, leave a +// non-empty complete-turn tail, include the prior usable marker, match the +// plan-versioned covered input digest, and come from the current Ready attempt +// (ADR#0035 facet 4). +message CompactSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string summary_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string summary_content = 3 [features.field_presence = LEGACY_REQUIRED]; + SessionOrdinal covers_from = 4 [features.field_presence = LEGACY_REQUIRED]; + SessionOrdinal covers_through = 5 [features.field_presence = LEGACY_REQUIRED]; + CompactionTrigger trigger = 6 [features.field_presence = LEGACY_REQUIRED]; + string guidance = 7; + uint64 tokens_before = 8; + uint64 tokens_after = 9; + string model = 10; + TokenUsage usage = 11; + CompactionContextRoot context_root = 12 [features.field_presence = LEGACY_REQUIRED]; + CompactionProducer producer = 13 [features.field_presence = LEGACY_REQUIRED]; + // Digest over the plan-versioned covered input, recomputed and compared + // before the cut is admitted. + Digest covered_input_digest = 14 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/complete_assistant_message.proto b/proto/trogonai/session/sessions/v1alpha1/complete_assistant_message.proto new file mode 100644 index 0000000000..e7cb7f79bf --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/complete_assistant_message.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/assistant_message_completed.proto"; +import "trogonai/session/sessions/v1alpha1/message.proto"; + +// CompleteAssistantMessage settles an assistant turn normally, recording +// [AssistantMessageCompleted]. +// +// Write precondition Any: per message_id this competes with +// FailAssistantMessage under first-terminal-outcome-wins, so ordering between +// them is decided by the fold rather than by a write guard. +message CompleteAssistantMessage { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + CanonicalMessage message = 2 [features.field_presence = LEGACY_REQUIRED]; + FinishReason finish_reason = 3 [features.field_presence = LEGACY_REQUIRED]; + // Set only when finish_reason is FINISH_REASON_STOP_SEQUENCE. + string matched_stop_sequence = 4; + string turn_id = 5 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/complete_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/complete_tool_call.proto new file mode 100644 index 0000000000..e011733e68 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/complete_tool_call.proto @@ -0,0 +1,41 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "google/protobuf/duration.proto"; +import "trogonai/session/sessions/v1alpha1/command_output_replay.proto"; +import "trogonai/session/sessions/v1alpha1/command_termination.proto"; +import "trogonai/session/sessions/v1alpha1/detached_work.proto"; +import "trogonai/session/sessions/v1alpha1/resource_access.proto"; +import "trogonai/session/sessions/v1alpha1/resource_observation.proto"; +import "trogonai/session/sessions/v1alpha1/target_outcome.proto"; +import "trogonai/session/sessions/v1alpha1/tool_call.proto"; + +// CompleteToolCall settles a call with a result, recording [ToolCallCompleted]. +// +// Write precondition Any: it races FailToolCall for the same execution, and the +// fold resolves that by first-terminal-outcome-wins keyed on +// tool_execution_id. A later conflicting outcome stays on the log, flagged by a +// projection, and never changes state. +message CompleteToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + ToolCallResult result = 4 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 5 [features.field_presence = LEGACY_REQUIRED]; + CommandTermination termination = 6; + google.protobuf.Duration duration = 7; + repeated ResourceObservation observed = 8; + // Captured stdout and stderr, already sealed and stored as an artifact by the + // time this command is issued. The capture is not part of the decision: a + // decider that had to write 40 MB before it could append would be one whose + // append latency is set by the noisiest command that ever ran. + CommandOutputReplayRef output_replay = 9; + // Set when the call is settling with a handle rather than an outcome. The + // work it names must already be reserved in the operation ledger, so the + // completion never points at an operation that does not exist. + DetachedWork detached = 10; + repeated ResourceAccessRecord accessed = 11; + repeated TargetOutcome failed_targets = 12; + uint32 targets_attempted = 13; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/content_chunks.proto b/proto/trogonai/session/sessions/v1alpha1/content_chunks.proto new file mode 100644 index 0000000000..00394b8f75 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/content_chunks.proto @@ -0,0 +1,38 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; + +// ContentChunks is what makes part of an artifact checkable without reading all +// of it. +// +// An artifact's Digest covers the whole artifact, so it can only be checked by +// hashing every byte. That is exactly what a range read exists to avoid: a +// caller fetching 64 KB of a 40 MB artifact cannot afford a 40 MB verification, +// and a caller who skips it is reading unverified bytes while holding a digest +// that looks like it proved something. +// +// So the artifact is also hashed in fixed-size chunks, and the digest of that +// ordered chunk-digest list is recorded here, on the log. A caller holding this +// value can fetch the chunk manifest from the artifact store, check the +// manifest against a value the store did not supply, and then check any chunk +// it reads against the manifest. Trust flows from the event log outward, which +// is the only direction in which it means anything: a manifest checked only +// against the store that served it proves the store is self-consistent. +// +// Optional on StoredArtifact. Absent means no range of that artifact can be +// checked, and the read contract says so rather than serving unchecked bytes +// that look checked. +message ContentChunks { + // Hash used for each chunk and for the manifest digest, for example "sha256". + string algorithm = 1 [features.field_presence = LEGACY_REQUIRED]; + // Size of every chunk but the last, which holds the remainder. + uint64 chunk_size_bytes = 2 [features.field_presence = LEGACY_REQUIRED]; + // Digest over the ordered chunk digests concatenated. + // + // The chunk count is deliberately not recorded: it follows from + // StoredArtifact.size_bytes and chunk_size_bytes, and a second field carrying + // a derivable fact is a second field that can disagree with the first. + Digest manifest_digest = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/copy_source.proto b/proto/trogonai/session/sessions/v1alpha1/copy_source.proto new file mode 100644 index 0000000000..6dd4da2a9e --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/copy_source.proto @@ -0,0 +1,31 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; + +// CopySource records where a copied file came from. +// +// A copy recorded only as a create loses the one fact that makes it reviewable. +// "A new file appeared at deploy/prod.yaml" and "deploy/staging.yaml was +// duplicated to deploy/prod.yaml" are different events for a reviewer, and the +// second is the one that raises the question worth raising. +// +// This is a distinct field rather than a reuse of FileChanged.previous_path, +// even though both name an earlier location, because the two make opposite +// claims about the source. After a rename the previous path is gone. After a +// copy the source still exists, unchanged, and anything that treated the two the +// same would report a file as moved that is still sitting there. +message CopySource { + // Workspace-relative path the content was copied from, in the same form as + // FileChanged.path. + string path = 1 [features.field_presence = LEGACY_REQUIRED]; + // What the source hashed to at the moment of the copy. + // + // This is what makes a copy checkable later, on the same reasoning as + // ResourceObservation: without it, a reader can see that prod.yaml came from + // staging.yaml but cannot tell whether it came from the staging.yaml that + // exists now or from a version since edited. Unset when the source content was + // not hashed. + Digest source_digest = 2; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/create_child_session.proto b/proto/trogonai/session/sessions/v1alpha1/create_child_session.proto new file mode 100644 index 0000000000..0b1cc1937e --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/create_child_session.proto @@ -0,0 +1,28 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/cascade_policy.proto"; +import "trogonai/session/sessions/v1alpha1/execution_plan.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/workspace.proto"; + +// CreateChildSession is the delegation saga's second step: it opens the +// delegated child's stream, recording [SessionStarted, ParentLinked] as one +// batch so a child can never exist without its lineage. +// +// Write precondition NoStream on the child. parent_dispatched_at and +// cascade_policy are copied verbatim from the parent's DelegationDispatched, so +// a redelivered saga step reproduces the same link (ADR#0035 facet 6). +message CreateChildSession { + // The child session's own id. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + StoredSessionExecutionPlan execution_plan = 2 [features.field_presence = LEGACY_REQUIRED]; + WorkspaceRef workspace = 3 [features.field_presence = LEGACY_REQUIRED]; + string parent_session_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // The parent's own ordinal of the DelegationDispatched being followed. + SessionOrdinal parent_dispatched_at = 5 [features.field_presence = LEGACY_REQUIRED]; + CascadePolicy cascade_policy = 6 [features.field_presence = LEGACY_REQUIRED]; + // The parent-side ledger operation this dispatch reserved. + string operation_id = 7 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/create_session.proto b/proto/trogonai/session/sessions/v1alpha1/create_session.proto new file mode 100644 index 0000000000..a135885a2e --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/create_session.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/execution_plan.proto"; +import "trogonai/session/sessions/v1alpha1/workspace.proto"; + +// CreateSession opens a session stream, recording [SessionStarted]. +// +// Write precondition NoStream: creation is atomic and exactly-once, so a +// redelivered create observes the stream already exists rather than forking a +// second history (ADR#0035 facet 2). The execution plan is immutable for the +// session's life; every later attempt, checkpoint, and compaction is bound to +// its digest. +message CreateSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + StoredSessionExecutionPlan execution_plan = 2 [features.field_presence = LEGACY_REQUIRED]; + WorkspaceRef workspace = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/deny_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/deny_tool_call.proto new file mode 100644 index 0000000000..54f4b34a99 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/deny_tool_call.proto @@ -0,0 +1,16 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// DenyToolCall records a human decision to refuse a call, recording +// [ToolCallDenied]. Denial is terminal for the call: it never starts. +// +// Write precondition At: mutually exclusive with approve. +message DenyToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string denied_by = 4 [features.field_presence = LEGACY_REQUIRED]; + string reason = 5; + string turn_id = 6; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/detach_delegation.proto b/proto/trogonai/session/sessions/v1alpha1/detach_delegation.proto new file mode 100644 index 0000000000..0424df580d --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/detach_delegation.proto @@ -0,0 +1,17 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// DetachDelegation releases a child from its parent, run against the parent +// side, recording [DelegationDetached]. After it, the parent's terminal state +// no longer cascades to that child. +// +// Write precondition At: one detach per detach_operation_id. The child-side +// half of the same intent is DetachParent. +message DetachDelegation { + // The parent session. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string child_session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string detach_operation_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string reason = 4; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/detach_parent.proto b/proto/trogonai/session/sessions/v1alpha1/detach_parent.proto new file mode 100644 index 0000000000..fc518414a0 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/detach_parent.proto @@ -0,0 +1,16 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// DetachParent releases a child from its parent, run against the child side, +// recording [ParentDetached]. It is the repair half of DetachDelegation: the +// two sides carry the same detach_operation_id, so a saga interrupted between +// them converges rather than leaving one side linked. +// +// Write precondition At: one detach per detach_operation_id. +message DetachParent { + // The child session. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string parent_session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string detach_operation_id = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/detached_work.proto b/proto/trogonai/session/sessions/v1alpha1/detached_work.proto new file mode 100644 index 0000000000..2e3537c978 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/detached_work.proto @@ -0,0 +1,93 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +// DetachedWork records that a tool call returned a handle while its work +// continued outside the turn. +// +// A development server is the ordinary case: the tool starts it, returns a URL, +// and the turn ends while the process keeps running and keeps producing output. +// Without this the completion is a lie of omission. `ToolCallCompleted` means +// the call finished, a reader folds it as done, and a process nobody is +// tracking outlives the session that started it. +// +// It is deliberately not a compound background-turn record. Everything durable +// about the work already has a home: `operation_id` joins the operation ledger, +// the eventual result arrives as `OperationOutcomeRecorded`, cancellation is +// `OperationCancellationRequested`, and captured output is a +// `CommandOutputReplayRef` sealed when the process ends. What was missing is +// only the fact that the turn was released first, plus the two policies nobody +// could otherwise infer. +message DetachedWork { + // The reserved operation this work continues under, joining to + // OperationReserved and the eventual OperationOutcomeRecorded. + // + // Required here, unlike ToolCallRequested.operation_id, which is empty for a + // call that reserves nothing. Work that outlives its turn has to be + // addressable to be cancellable, and an unaddressable detached process is the + // thing this message exists to prevent. + string operation_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Wall-clock instant the turn was released, a real external occurrence + // distinct from envelope append time (D10). + google.protobuf.Timestamp detached_at = 2 [features.field_presence = LEGACY_REQUIRED]; + // What happens to this work when the session reaches a terminal state. + TerminalOwnership terminal_ownership = 3 [features.field_presence = LEGACY_REQUIRED]; + // How long the work may go unsupervised before a runner is presumed lost. + SupervisionPolicy supervision = 4 [features.field_presence = LEGACY_REQUIRED]; + // Where the caller can reach what was started: a URL, a socket path, a + // container id. Empty when the work exposes nothing addressable. + // + // Must be credential-free, the same prohibition ExternalArtifact.source_url + // carries (D7). A detached development server's URL is the field most likely + // to arrive with a session token stapled to it. + string endpoint = 5; +} + +// TerminalOwnership is what becomes of detached work when its session ends. +// +// The zero value cancels, because the two failure modes are not symmetric. +// Cancelling work that should have survived is visible: something the user +// wanted stopped, and they find out. Leaving work running that should have +// stopped is invisible, and it is the orphan problem in +// `doctor/v1alpha1/orphan.proto` with a process attached instead of a byte +// range. +enum TerminalOwnership { + // Unknown policy. Treat as CANCEL_ON_TERMINAL. + TERMINAL_OWNERSHIP_UNSPECIFIED = 0; + // Cancel the operation when the session reaches a terminal state. + TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL = 1; + // Let the work continue past the session's terminal state. + // + // The session still owns the record of it. A terminal session with surviving + // detached work is exactly the case `SessionView.has_unreconciled_work` + // exists for: terminal is not the same as complete, and a reader that treats + // them as the same will report a session as finished while its work is still + // running. + TERMINAL_OWNERSHIP_SURVIVE_TERMINAL = 2; +} + +// SupervisionPolicy is how a lost runner becomes detectable. +// +// It records the policy and never the heartbeat. A renewal per interval would +// be an append per interval, into a log that is never truncated +// (ADR#0035 facet 7), and long-lived detached work is precisely the case that +// generates the most of them. That is the same reason FX-23 keeps a downstream +// consumer's checkpoint flood out of Session streams: liveness is live state, +// and live state belongs in the runner registry that a projection reads, not in +// the history that outlives it. +// +// What the log holds is the number a reconciler needs afterwards. Given +// `max_unsupervised` and the last observed supervision, whether a runner is +// lost is a question anyone can answer later without having watched. +message SupervisionPolicy { + // How long the work may run without an observed supervisor before it is + // presumed abandoned and becomes a reconciliation candidate. + google.protobuf.Duration max_unsupervised = 1 [features.field_presence = LEGACY_REQUIRED]; + // Identity of the runner that held the work at detach time. Opaque, and + // recorded so a reconciler can tell work whose runner is gone from work whose + // runner is merely quiet. + string runner_id = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/dispatch_delegation.proto b/proto/trogonai/session/sessions/v1alpha1/dispatch_delegation.proto new file mode 100644 index 0000000000..0ed75f64e7 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/dispatch_delegation.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/cascade_policy.proto"; + +// DispatchDelegation is the delegation saga's first step, run against the +// parent: it records [DelegationDispatched], naming the child and what happens +// to it when the parent reaches a terminal state. +// +// Write precondition At: one dispatch per operation_id, and the parent must not +// already be terminal. +message DispatchDelegation { + // The parent session. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string operation_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string child_session_id = 3 [features.field_presence = LEGACY_REQUIRED]; + // Recorded at dispatch so an orphaned child is never a silent accident + // (ADR#0035 facet 6). + CascadePolicy cascade_policy = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/dispatch_external_delegation.proto b/proto/trogonai/session/sessions/v1alpha1/dispatch_external_delegation.proto new file mode 100644 index 0000000000..38ba042437 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/dispatch_external_delegation.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; + +// DispatchExternalDelegation hands work to an agent outside this store, +// recording [ExternalDelegationDispatched]. +// +// Write precondition At: one dispatch per operation_id. +message DispatchExternalDelegation { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string operation_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string delegate_reference = 3 [features.field_presence = LEGACY_REQUIRED]; + string authenticated_remote_subject = 4 [features.field_presence = LEGACY_REQUIRED]; + string authorization_reference = 5 [features.field_presence = LEGACY_REQUIRED]; + Digest request_digest = 6 [features.field_presence = LEGACY_REQUIRED]; + string correlation_id = 7 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/end_execution_attempt.proto b/proto/trogonai/session/sessions/v1alpha1/end_execution_attempt.proto new file mode 100644 index 0000000000..93c2c82937 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/end_execution_attempt.proto @@ -0,0 +1,18 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/v1alpha1/execution_attempt_ended.proto"; + +// EndExecutionAttempt releases the session from an attempt, recording +// [ExecutionAttemptEnded]. +// +// Write precondition At: one outcome per attempt. +message EndExecutionAttempt { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string execution_attempt_id = 2 [features.field_presence = LEGACY_REQUIRED]; + AttemptOutcome outcome = 3 [features.field_presence = LEGACY_REQUIRED]; + string detail = 4; + google.protobuf.Timestamp ended_at = 5 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/erase_artifact.proto b/proto/trogonai/session/sessions/v1alpha1/erase_artifact.proto new file mode 100644 index 0000000000..4dcc69fb03 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/erase_artifact.proto @@ -0,0 +1,16 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// EraseArtifact removes claim-checked bytes an event referenced, recording +// [ArtifactErased]. The event that referenced them stays on the log; only the +// out-of-line payload goes. +// +// Write precondition At: the artifact must exist and be claim-checked, verified +// at the command boundary against the artifact store rather than from folded +// state. +message EraseArtifact { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string artifact_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string reason = 3; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/events.proto b/proto/trogonai/session/sessions/v1alpha1/events.proto index 5d4fd410ca..bffebb8d24 100644 --- a/proto/trogonai/session/sessions/v1alpha1/events.proto +++ b/proto/trogonai/session/sessions/v1alpha1/events.proto @@ -23,6 +23,7 @@ import "trogonai/session/sessions/v1alpha1/parent_detached.proto"; import "trogonai/session/sessions/v1alpha1/parent_history_invalidated.proto"; import "trogonai/session/sessions/v1alpha1/parent_linked.proto"; import "trogonai/session/sessions/v1alpha1/parent_terminated.proto"; +import "trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto"; import "trogonai/session/sessions/v1alpha1/redaction_applied.proto"; import "trogonai/session/sessions/v1alpha1/session_archived.proto"; import "trogonai/session/sessions/v1alpha1/session_cancelled.proto"; @@ -30,6 +31,7 @@ import "trogonai/session/sessions/v1alpha1/session_closed.proto"; import "trogonai/session/sessions/v1alpha1/session_failed.proto"; import "trogonai/session/sessions/v1alpha1/session_forked.proto"; import "trogonai/session/sessions/v1alpha1/session_hidden.proto"; +import "trogonai/session/sessions/v1alpha1/session_recovered.proto"; import "trogonai/session/sessions/v1alpha1/session_renamed.proto"; import "trogonai/session/sessions/v1alpha1/session_rewound.proto"; import "trogonai/session/sessions/v1alpha1/session_started.proto"; @@ -79,6 +81,10 @@ message SessionEvent { // Fork and rewind. SessionForked session_forked = 6; SessionRewound session_rewound = 7; + // Salvage. A recovery is not a fork: it copies a damaged source rather than + // referencing an intact prefix of it, so the copied events are this + // session's own and the source's ordinals do not carry over. + SessionRecovered session_recovered = 42; // Compaction. Compacted compacted = 8; // Conversation. @@ -87,6 +93,7 @@ message SessionEvent { AssistantMessageCompleted assistant_message_completed = 11; AssistantMessageFailed assistant_message_failed = 28; // Tool lifecycle. + ProviderToolIntentRejected provider_tool_intent_rejected = 43; ToolCallRequested tool_call_requested = 12; ToolCallApproved tool_call_approved = 13; ToolCallDenied tool_call_denied = 29; diff --git a/proto/trogonai/session/sessions/v1alpha1/fail_assistant_message.proto b/proto/trogonai/session/sessions/v1alpha1/fail_assistant_message.proto new file mode 100644 index 0000000000..f2bc2d4c2d --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/fail_assistant_message.proto @@ -0,0 +1,23 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/assistant_message_failed.proto"; +import "trogonai/session/sessions/v1alpha1/token_usage.proto"; + +// FailAssistantMessage settles an assistant turn that was interrupted, +// cancelled, or errored, recording [AssistantMessageFailed], so every started +// message has a determinable outcome. +// +// Write precondition Any: per message_id this competes with +// CompleteAssistantMessage under first-terminal-outcome-wins. +message FailAssistantMessage { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string message_id = 2 [features.field_presence = LEGACY_REQUIRED]; + AssistantMessageFailureReason reason = 3 [features.field_presence = LEGACY_REQUIRED]; + string detail = 4; + // Tokens billed for the partial turn, so a cost fold does not undercount + // a turn that failed mid-generation. + TokenUsage usage = 5; + string turn_id = 6 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/fail_session.proto b/proto/trogonai/session/sessions/v1alpha1/fail_session.proto new file mode 100644 index 0000000000..4d1038ca16 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/fail_session.proto @@ -0,0 +1,14 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_failed.proto"; + +// FailSession seals a session as failed, recording [SessionFailed]. +// +// Write precondition At: rejected if the session is already terminal. +message FailSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionFailureReason reason = 2 [features.field_presence = LEGACY_REQUIRED]; + string detail = 3; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/fail_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/fail_tool_call.proto new file mode 100644 index 0000000000..6943e86240 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/fail_tool_call.proto @@ -0,0 +1,20 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/tool_call_failed.proto"; + +// FailToolCall settles a call with an error, recording [ToolCallFailed]. It is +// how a reconciler rejects a call it found interrupted, with reason +// TOOL_CALL_FAILURE_REASON_INTERRUPTED. +// +// Write precondition Any: first-terminal-outcome-wins against CompleteToolCall, +// keyed on tool_execution_id. +message FailToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string error = 4 [features.field_presence = LEGACY_REQUIRED]; + ToolCallFailureReason reason = 5 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 6 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/file_change.proto b/proto/trogonai/session/sessions/v1alpha1/file_change.proto index c4912fae32..ac26c8dbf4 100644 --- a/proto/trogonai/session/sessions/v1alpha1/file_change.proto +++ b/proto/trogonai/session/sessions/v1alpha1/file_change.proto @@ -9,4 +9,9 @@ enum FileChangeKind { FILE_CHANGE_KIND_MODIFIED = 2; FILE_CHANGE_KIND_DELETED = 3; FILE_CHANGE_KIND_RENAMED = 4; + // Content duplicated from another path, which still exists. Recorded instead + // of FILE_CHANGE_KIND_CREATED rather than alongside it, so the destination has + // exactly one kind and two facts about the same change cannot disagree. The + // source file did not change and produces no FileChanged of its own. + FILE_CHANGE_KIND_COPIED = 5; } diff --git a/proto/trogonai/session/sessions/v1alpha1/file_changed.proto b/proto/trogonai/session/sessions/v1alpha1/file_changed.proto index 7be1aca94f..f563ebc57a 100644 --- a/proto/trogonai/session/sessions/v1alpha1/file_changed.proto +++ b/proto/trogonai/session/sessions/v1alpha1/file_changed.proto @@ -3,6 +3,7 @@ edition = "2024"; package trogonai.session.sessions.v1alpha1; import "trogonai/session/sessions/v1alpha1/artifact.proto"; +import "trogonai/session/sessions/v1alpha1/copy_source.proto"; import "trogonai/session/sessions/v1alpha1/diff_summary.proto"; import "trogonai/session/sessions/v1alpha1/file_change.proto"; @@ -25,7 +26,9 @@ message FileChanged { // with no FileChanged to join against. string path = 2 [features.field_presence = LEGACY_REQUIRED]; FileChangeKind change_kind = 3 [features.field_presence = LEGACY_REQUIRED]; - // Same workspace-relative form as path. + // Where a renamed file used to be, in the same workspace-relative form as + // path. Rename only: a copy sets copied_from instead, because a previous path + // asserts the file is no longer there. string previous_path = 4; // Claim-check to the file's content before the change; unset for a create or // when content was not captured. Recorded because our checkpoints are opaque, @@ -43,4 +46,6 @@ message FileChanged { string turn_id = 8 [features.field_presence = LEGACY_REQUIRED]; // Precomputed line counts and rendered diff; unset when no diff was computed. DiffSummary diff = 9; + // Where the content came from, set only for FILE_CHANGE_KIND_COPIED. + CopySource copied_from = 10; } diff --git a/proto/trogonai/session/sessions/v1alpha1/fork_session.proto b/proto/trogonai/session/sessions/v1alpha1/fork_session.proto new file mode 100644 index 0000000000..89229df4f7 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/fork_session.proto @@ -0,0 +1,26 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/execution_plan.proto"; +import "trogonai/session/sessions/v1alpha1/session_forked.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/workspace.proto"; + +// ForkSession opens a child stream that inherits a prefix of another session's +// context, recording [SessionStarted, SessionForked] as one batch. +// +// Write precondition NoStream on the new stream. The source's existence is +// checked at the command boundary, not by the fold: the source is a different +// aggregate and this decider never reads it. The plan and workspace are carried +// rather than inherited for the same reason. +message ForkSession { + // The new session's own id. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + StoredSessionExecutionPlan execution_plan = 2 [features.field_presence = LEGACY_REQUIRED]; + WorkspaceRef workspace = 3 [features.field_presence = LEGACY_REQUIRED]; + string source_session_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // The source's own ordinal the inherited prefix ends at. + SessionOrdinal context_prefix_boundary = 5 [features.field_presence = LEGACY_REQUIRED]; + ForkReason reason = 6 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/hide_session.proto b/proto/trogonai/session/sessions/v1alpha1/hide_session.proto new file mode 100644 index 0000000000..08ea33c34e --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/hide_session.proto @@ -0,0 +1,14 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_hidden.proto"; + +// HideSession seals a session as hidden, recording [SessionHidden]. Hiding is a +// terminal marker, not a deletion: no bytes are removed (ADR#0035 facet 5). +// +// Write precondition At. +message HideSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + SessionHiddenReason reason = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/mark_execution_attempt_ready.proto b/proto/trogonai/session/sessions/v1alpha1/mark_execution_attempt_ready.proto new file mode 100644 index 0000000000..cdcbd38cf2 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/mark_execution_attempt_ready.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/v1alpha1/digest.proto"; + +// MarkExecutionAttemptReady publishes an attempt's ready attestation, recording +// [ExecutionAttemptReady]. +// +// Write precondition At: Ready only after Started, and for a restore only after +// verified artifact recovery plus effective-tail replay through the start head. +message MarkExecutionAttemptReady { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string execution_attempt_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string ready_attestation_ref = 3 [features.field_presence = LEGACY_REQUIRED]; + Digest ready_attestation_digest = 4 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp ready_at = 5 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/produce_checkpoint.proto b/proto/trogonai/session/sessions/v1alpha1/produce_checkpoint.proto new file mode 100644 index 0000000000..1856fbac65 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/produce_checkpoint.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/checkpoint.proto"; + +// ProduceCheckpoint records opaque durable state an execution attempt captured +// mid-run, recording [CheckpointProduced], so a later attempt can restore it +// instead of replaying from the beginning. +// +// Write precondition Any: the first evidence admitted per checkpoint_id wins; a +// later event reusing the id stays on the log but never replaces it, so a +// restore always resolves to the same bytes. +message ProduceCheckpoint { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Self-describing: checkpoint id, producing attempt, covered boundary, + // and the execution plan digest it is bound to all live here. + Checkpoint checkpoint = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto b/proto/trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto new file mode 100644 index 0000000000..ea04a59f2b --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto @@ -0,0 +1,95 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; + +// ProviderToolIntentRejected records that a provider emitted something shaped +// like a tool call which the runtime refused to turn into one. +// +// It exists because the malformed intent structurally cannot be stored anywhere +// else. The canonical transcript form is `ToolUseBlock`, whose `input_json` is +// LEGACY_REQUIRED and must be valid JSON; an intent whose arguments are truncated +// JSON has nothing to put there. `ProviderBlock` retains the raw payload but is +// documented write-verbatim, read-never, so mining it for diagnosis would make a +// projection depend on a shape the domain promised never to interpret. The +// choice is therefore a typed event or nothing, and nothing means the most +// common provider fault in production leaves a session that simply did less than +// it appeared to. +// +// This is not ToolCallDenied. Denial is a well-formed request a human, policy, +// or hook refused, and the request exists. Here no request was ever admissible, +// so no ToolCallRequested is written, no execution id is minted, and no +// operation is reserved. Refusing to synthesize a request out of unparseable +// input is the whole point: a synthetic ToolCallRequested would put a call on the +// log that the provider never validly asked for. +// +// It is per-intent and not per-message. A message carrying nine sound tool calls +// and one malformed one must keep the nine, so the sound calls proceed to +// ToolCallRequested normally while only the tenth lands here. Marking the whole +// assistant message failed would discard nine calls to describe one. +// +// It is a commuting happened-fact (WRITE_PRECONDITION = Any, ADR#0035 facet 2). +// It records something the provider already did; nothing about the session's +// current lifecycle can make it untrue. +message ProviderToolIntentRejected { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Identifies this rejection. Minted by the runtime, because the whole class of + // fault is that the provider's own identifier is missing, empty, or duplicated + // and cannot be used as a key. + string rejection_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // The assistant message this intent arrived in (CanonicalMessage.message_id). + string message_id = 3 [features.field_presence = LEGACY_REQUIRED]; + // Turn this generation belongs to (see UserMessageRecorded.turn_id). + string turn_id = 4 [features.field_presence = LEGACY_REQUIRED]; + ProviderToolIntentRejectionReason reason = 5 [features.field_presence = LEGACY_REQUIRED]; + // What the provider claimed the call's id was, verbatim, including empty when + // that was the fault. Recorded as a claim rather than as an identity: it may + // be empty, may collide with a real call, and must never be joined against + // tool_call_id anywhere. + string claimed_tool_call_id = 6; + // What the provider claimed the tool's name was, verbatim. Empty when absent. + string claimed_tool_name = 7; + // Claim-check to the provider's raw emission for this intent. + // + // Out of line rather than inline for the reason every other unbounded payload + // is: malformed input has no length bound, and this particular payload is the + // one shaped by whatever produced the fault. A megabyte of truncated JSON + // inlined into a never-truncated log is a way to make one bad generation + // permanent for every reader of the stream. + // + // Unset when the raw emission could not be captured, which is itself worth + // distinguishing from a capture of nothing. + ArtifactRef raw_intent = 8; + // Free-text detail from the parser or validator, for humans. Never parsed. + string detail = 9; +} + +// ProviderToolIntentRejectionReason is why the intent was not admissible. +// +// The reasons are typed because the operational responses differ: a malformed +// argument payload is a prompt or model problem, an unknown tool name is a +// catalog drift problem, and a duplicate id is a provider bug that will corrupt +// joins if it is ever admitted. A single free-text reason makes those one alert. +enum ProviderToolIntentRejectionReason { + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED = 0; + // Arguments were not parseable as JSON, or parsed to something that is not an + // object. + PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS = 1; + // Arguments parsed but did not satisfy the tool's declared input schema. + PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION = 2; + // The provider supplied no call id, or an empty one. + PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID = 3; + // The call id collides with one already used in this session. Refused rather + // than deduplicated: admitting it would make the result of one call + // attributable to another, and every downstream join silently wrong. + PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID = 4; + // No tool name, or a name no registered tool answers to. + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL = 5; + // The intent named a parent tool use that does not exist in this session, so + // its position in the call tree is unresolvable. + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT = 6; + // The emission exceeded the runtime's accepted size for a single intent and + // was refused before parsing. + PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED = 7; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_rewind.proto b/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_rewind.proto new file mode 100644 index 0000000000..628f0d209d --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_rewind.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; + +// ReconcileParentRewind is issued by the child-session reconciler when a parent +// rewinds past the dispatch that created a child, recording +// [ParentHistoryInvalidated, SessionCancelled] as one batch: the context the +// child inherited no longer exists. +// +// Write precondition At on the child: applies only when parent_dispatched_at is +// past the parent's new boundary and the cascade policy allows it. +message ReconcileParentRewind { + // The child session being reconciled. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string parent_session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // The parent's new effective boundary. + SessionOrdinal parent_keep_through = 3 [features.field_presence = LEGACY_REQUIRED]; + string triggering_event_id = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_terminal.proto b/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_terminal.proto new file mode 100644 index 0000000000..fb56e10704 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/reconcile_parent_terminal.proto @@ -0,0 +1,22 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/parent_terminated.proto"; + +// ReconcileParentTerminal is issued by the child-session reconciler when a +// parent reaches a terminal state, recording [ParentTerminated, +// SessionCancelled] against the child as one batch. Recording the observation +// and the consequence together is what closes the silent-orphan gap. +// +// Write precondition At on the child: a no-op if the child is already terminal. +// The cancellation reason is derived by the aggregate, not carried here. +message ReconcileParentTerminal { + // The child session being reconciled. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string parent_session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + ParentTerminalCause cause = 3 [features.field_presence = LEGACY_REQUIRED]; + // The parent event that triggered this reconcile, so a redelivery is + // recognisable as the same observation. + string triggering_event_id = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/record_artifact.proto b/proto/trogonai/session/sessions/v1alpha1/record_artifact.proto new file mode 100644 index 0000000000..aee3f26140 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/record_artifact.proto @@ -0,0 +1,14 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; + +// RecordArtifact registers an artifact by claim-check, recording +// [ArtifactRecorded]. Bytes are never inlined on the log (ADR#0035 facet 3). +// +// Write precondition Any. +message RecordArtifact { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + ArtifactMetadata artifact = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/record_file_change.proto b/proto/trogonai/session/sessions/v1alpha1/record_file_change.proto new file mode 100644 index 0000000000..37548ed21c --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/record_file_change.proto @@ -0,0 +1,32 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; +import "trogonai/session/sessions/v1alpha1/diff_summary.proto"; +import "trogonai/session/sessions/v1alpha1/file_change.proto"; + +// RecordFileChange attributes a workspace file change to the tool call that +// caused it, recording [FileChanged]. A change with no proximate call is not +// this command: it surfaces as a ResourceObservation whose digest moved, +// meaning something outside the session touched the file. +// +// Write precondition Any. +message RecordFileChange { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Workspace-relative, forward slashes, no leading slash. + string path = 2 [features.field_presence = LEGACY_REQUIRED]; + FileChangeKind change_kind = 3 [features.field_presence = LEGACY_REQUIRED]; + string previous_path = 4; + // Content before the change; unset for a create or when not captured. + // Recorded because checkpoints are opaque, so what changed is not + // re-derivable by diffing them afterwards. + ArtifactRef before_ref = 5; + ArtifactRef after_ref = 6; + // The causing call. Without it, which call touched this file is only + // answerable by fold adjacency, which concurrent Any appends make + // unsound. + string tool_call_id = 7 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 8 [features.field_presence = LEGACY_REQUIRED]; + DiffSummary diff = 9; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/record_operation_outcome.proto b/proto/trogonai/session/sessions/v1alpha1/record_operation_outcome.proto new file mode 100644 index 0000000000..d161661081 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/record_operation_outcome.proto @@ -0,0 +1,26 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/operation_outcome_recorded.proto"; + +// RecordOperationOutcome settles a reserved operation, recording +// [OperationOutcomeRecorded]. It is how an interrupted side effect stops being +// in flight, and it stays admissible after the session is terminal so work +// stranded by a cancellation can still be reconciled. +// +// Write precondition At: one determinate outcome per operation_id. An `unknown` +// outcome is not determinate; it may be superseded exactly once by a +// determinate one. +message RecordOperationOutcome { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string operation_id = 2 [features.field_presence = LEGACY_REQUIRED]; + oneof outcome { + OperationSucceeded succeeded = 3; + OperationFailed failed = 4; + OperationCancelled cancelled = 5; + // Indeterminate: the side effect may or may not have run. Non-terminal, and + // supersedable exactly once. + OperationUnknown unknown = 6; + } +} diff --git a/proto/trogonai/session/sessions/v1alpha1/record_system_notice.proto b/proto/trogonai/session/sessions/v1alpha1/record_system_notice.proto new file mode 100644 index 0000000000..883a6f7c7c --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/record_system_notice.proto @@ -0,0 +1,18 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/system_notice_recorded.proto"; + +// RecordSystemNotice appends a system-originated notice, recording +// [SystemNoticeRecorded], so model-visible system content and the user-visible +// transcript both rebuild from the log alone (ADR#0035 facet 8). +// +// Write precondition Any. +message RecordSystemNotice { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + NoticeLevel level = 2 [features.field_presence = LEGACY_REQUIRED]; + string text = 3 [features.field_presence = LEGACY_REQUIRED]; + // Set when the notice concerns a specific call. + string tool_call_id = 4; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/record_user_message.proto b/proto/trogonai/session/sessions/v1alpha1/record_user_message.proto new file mode 100644 index 0000000000..5463c61e19 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/record_user_message.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/message.proto"; + +// RecordUserMessage appends a user message, recording [UserMessageRecorded]. +// +// Write precondition Any: arrival of a message is a happened-fact that commutes +// with other appends and carries no invariant a concurrent writer could break +// (ADR#0035 facet 2). +message RecordUserMessage { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + CanonicalMessage message = 2 [features.field_presence = LEGACY_REQUIRED]; + // The turn this message opens; every event produced within the turn + // repeats it, because the fold cannot recover a boundary that concurrent + // Any appends give no reliable ordering for. + string turn_id = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/recover_session.proto b/proto/trogonai/session/sessions/v1alpha1/recover_session.proto new file mode 100644 index 0000000000..6bbe2760e3 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/recover_session.proto @@ -0,0 +1,36 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; +import "trogonai/session/sessions/v1alpha1/execution_plan.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/session_recovered.proto"; +import "trogonai/session/sessions/v1alpha1/workspace.proto"; + +// RecoverSession opens a session carrying what a salvage could read from a +// damaged source, recording [SessionStarted, SessionRecovered] as one batch. +// +// Write precondition NoStream on the new stream. The source is a different +// aggregate and this decider never reads it, so what the salvage found is +// carried on the command rather than derived here; the same rule ForkSession +// follows. The NoStream precondition is what makes a retried salvage safe: a +// second attempt derives the same session_id and is rejected instead of +// producing a second copy. +// +// The salvaged events themselves are appended after this batch, as this +// session's own events. This command records only that the session is a +// recovery and how complete it is. +message RecoverSession { + // Derived from the salvage identity, never randomly minted. + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + StoredSessionExecutionPlan execution_plan = 2 [features.field_presence = LEGACY_REQUIRED]; + WorkspaceRef workspace = 3 [features.field_presence = LEGACY_REQUIRED]; + string source_session_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // The last source ordinal the salvage drew from. + SessionOrdinal source_boundary = 5 [features.field_presence = LEGACY_REQUIRED]; + Digest source_digest = 6 [features.field_presence = LEGACY_REQUIRED]; + string salvage_key = 7 [features.field_presence = LEGACY_REQUIRED]; + RecoveryCompleteness completeness = 8 [features.field_presence = LEGACY_REQUIRED]; + uint32 omitted_count = 9 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto b/proto/trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto new file mode 100644 index 0000000000..13fcb1cedb --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto @@ -0,0 +1,28 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; +import "trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto"; + +// RejectProviderToolIntent records a refused provider tool intent, producing +// [ProviderToolIntentRejected]. +// +// Write precondition Any: the provider already emitted it, and no lifecycle +// state can retract that. +// +// The raw emission is stored as an artifact before this command is issued, for +// the same reason captured command output is: a decider that must write an +// unbounded attacker-shaped payload before it can append has an append latency +// set by the worst input it ever received. +message RejectProviderToolIntent { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string rejection_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string message_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 4 [features.field_presence = LEGACY_REQUIRED]; + ProviderToolIntentRejectionReason reason = 5 [features.field_presence = LEGACY_REQUIRED]; + string claimed_tool_call_id = 6; + string claimed_tool_name = 7; + ArtifactRef raw_intent = 8; + string detail = 9; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/rename_session.proto b/proto/trogonai/session/sessions/v1alpha1/rename_session.proto new file mode 100644 index 0000000000..2e3157bf8d --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/rename_session.proto @@ -0,0 +1,13 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// RenameSession changes the session's display name, recording +// [SessionRenamed]. Reversible organization state, unlike the terminal +// HideSession. +// +// Write precondition Any. +message RenameSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string display_name = 2 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/request_operation_cancellation.proto b/proto/trogonai/session/sessions/v1alpha1/request_operation_cancellation.proto new file mode 100644 index 0000000000..3217d3bd93 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/request_operation_cancellation.proto @@ -0,0 +1,14 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// RequestOperationCancellation asks for an in-flight side effect to stop, +// recording [OperationCancellationRequested]. Asking is not settling: the +// operation still needs a recorded outcome before it leaves the ledger. +// +// Write precondition At: rejected if the operation is already terminal. +message RequestOperationCancellation { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string operation_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string reason = 3; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/request_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/request_tool_call.proto new file mode 100644 index 0000000000..5ca5049d12 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/request_tool_call.proto @@ -0,0 +1,23 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// RequestToolCall records that the model asked for a tool, recording +// [ToolCallRequested]. +// +// Write precondition Any: this is the aggregate's highest-volume path and it +// commutes with everything else, so it never coordinates and never retries. +message RequestToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Identity of the request. Approval, denial, and start all join on it. + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Retry identity of this execution of the call. The terminal outcome joins + // on it, so a re-execution settles the attempt it belongs to. + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string tool_name = 4 [features.field_presence = LEGACY_REQUIRED]; + string input_json = 5 [features.field_presence = LEGACY_REQUIRED]; + string parent_tool_use_id = 6; + // The ledger operation guarding this call's side effect, when it reserves one. + string operation_id = 7; + string turn_id = 8 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/reserve_operation.proto b/proto/trogonai/session/sessions/v1alpha1/reserve_operation.proto new file mode 100644 index 0000000000..461c75b1c9 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/reserve_operation.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; +import "trogonai/session/sessions/v1alpha1/operation_reserved.proto"; + +// ReserveOperation claims an operation id and its request bytes before a side +// effect runs, recording [OperationReserved]. +// +// Write precondition At: this is what makes reserve-and-check atomic. One +// reservation per operation_id; a retry carrying different bytes under the same +// id is a contract violation, not a duplicate (ADR#0035 facet 3). +message ReserveOperation { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string operation_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Digest of the request the id is reserved for, so a retry with different + // bytes is refused instead of executed as if it were the same call. + Digest request_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + OperationKind operation_kind = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/resource_access.proto b/proto/trogonai/session/sessions/v1alpha1/resource_access.proto new file mode 100644 index 0000000000..780fa0dae2 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/resource_access.proto @@ -0,0 +1,93 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/artifact.proto"; + +// ResourceAccessRecord records what a tool call did to a namespace of +// resources, as distinct from what content it read. +// +// It exists because ResourceObservation deliberately answers only one question. +// An observation means content entered the model's context, and its digest is +// what makes a later write checkable. A search that walks a directory of +// sensitive filenames and returns none of their contents produces no +// observation, correctly, and yet something happened that a compliance reviewer +// has to be able to see: the agent learned that those files exist and what they +// are called. +// +// The two must stay separate rather than merging into one weakened observation. +// "Did the agent read this file" and "did the agent see this file's name" are +// different questions with different answers and different consequences, and a +// single record that means either makes both unanswerable. +// +// Records are per-scope, never per-path. That is the same volume argument that +// keeps reads off their own event: a search can walk forty thousand paths, and +// forty thousand facts appended to a log that is never truncated +// (ADR#0035 facet 7) would make the dominant content of a session stream the +// output of one grep. The scope plus the counts is what a reviewer needs to know +// what was exposed; the path list itself, when it is worth keeping, goes out of +// line as an artifact and is erasable like any other artifact while the counts +// survive it. +message ResourceAccessRecord { + ResourceAction action = 1 [features.field_presence = LEGACY_REQUIRED]; + // The namespace this access covered, as a URI prefix or a glob in the same URI + // form as WorkspaceRef.uri. This is the extent of exposure, not a single + // resource: a directory listing's scope is the directory, and a recursive + // search's scope is its root. + string scope = 2 [features.field_presence = LEGACY_REQUIRED]; + // Resources within scope the tool actually enumerated back to the caller. For + // a search this is the hit count, which is the number that matters, since + // knowing that four files in a secrets directory matched "password" is a + // different disclosure from knowing the directory has four hundred files. + uint64 matched = 3 [features.field_presence = LEGACY_REQUIRED]; + // Resources within scope the tool traversed to produce that answer. Recorded + // apart from `matched` because traversal is itself access to a namespace: a + // filter that rejected a path still required reading the path's name. + uint64 traversed = 4 [features.field_presence = LEGACY_REQUIRED]; + // True when the tool covered its scope entirely. False when it stopped at a + // result limit, a depth limit, or a timeout, so a reviewer never reads a + // truncated enumeration as a complete inventory of what was exposed. + bool complete = 5 [features.field_presence = LEGACY_REQUIRED]; + // Claim-check to the enumerated resource identifiers, when they were kept. + // + // Unset is ordinary and does not weaken the record: the counts and the scope + // stand on their own. It is a claim-check rather than a repeated string for + // the volume reason above, and being an artifact is also what makes the list + // erasable under a deletion request while leaving the audit fact that an + // enumeration happened permanently intact. + ArtifactRef enumerated = 6; +} + +// ResourceAction is what was done to a namespace, in the terms an access policy +// is written in. +// +// The distinction the taxonomy exists for is between the actions that expose +// names and the actions that expose or alter content. LIST and SEARCH disclose +// a namespace. READ discloses content. The mutating actions change it. A policy +// that cannot separate those cannot express "this agent may find files here but +// may not open them", which is a rule real deployments have. +enum ResourceAction { + RESOURCE_ACTION_UNSPECIFIED = 0; + // Enumerated the names within a scope, without reading contents. + RESOURCE_ACTION_LIST = 1; + // Matched contents within a scope and returned locations or excerpts. Content + // that actually entered the model's context is separately a + // ResourceObservation; a search that returned only paths is not. + RESOURCE_ACTION_SEARCH = 2; + // Read content. Paired with a ResourceObservation carrying the digest. + RESOURCE_ACTION_READ = 3; + // Created or overwrote content. + RESOURCE_ACTION_WRITE = 4; + // Modified existing content in place. + RESOURCE_ACTION_EDIT = 5; + // Removed resources. + RESOURCE_ACTION_DELETE = 6; + // Moved or renamed resources. + RESOURCE_ACTION_RENAME = 7; + // Duplicated resources to a new location. + RESOURCE_ACTION_COPY = 8; + // Changed permissions, ownership, or other metadata without changing content. + RESOURCE_ACTION_CHANGE_METADATA = 9; + // Executed a resource as a program. + RESOURCE_ACTION_EXECUTE = 10; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/rewind_session.proto b/proto/trogonai/session/sessions/v1alpha1/rewind_session.proto new file mode 100644 index 0000000000..5265b4b449 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/rewind_session.proto @@ -0,0 +1,19 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; +import "trogonai/session/sessions/v1alpha1/session_rewound.proto"; + +// RewindSession moves the effective-history boundary back, recording +// [SessionRewound]. It masks what later turns and readers see; it never +// un-applies a fact, because work that really ran still has to be reconcilable. +// +// Write precondition At: keep_through must lie within the log the decision was +// taken against. +message RewindSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // This session's own ordinal that stays effective; everything after it is masked. + SessionOrdinal keep_through = 2 [features.field_presence = LEGACY_REQUIRED]; + RewindReason reason = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/session_recovered.proto b/proto/trogonai/session/sessions/v1alpha1/session_recovered.proto new file mode 100644 index 0000000000..bd0f51a0a1 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/session_recovered.proto @@ -0,0 +1,52 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/digest.proto"; +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; + +// SessionRecovered is the second event in the atomic +// [SessionStarted, SessionRecovered] creation batch appended to a salvaged +// session's subject under the NoStream precondition, making salvage creation +// atomic and exactly-once (ADR#0035 facet 2). +// +// It exists as an event rather than only as a maintenance record because a +// reader folding this stream alone must be able to tell that this session is a +// copy of a damaged one. A projection is rebuilt from the stream, so provenance +// that lived only in an operator-side journal would be lost on the next rebuild +// and the session would then read as an ordinary session with a short history. +// +// This is not SessionForked. A fork inherits its source by reference within +// context_prefix_boundary and depends on the source staying readable; a +// recovery copies, because the source's readability is the thing that failed. +// The copied events are this session's own events at this session's own +// ordinals: source ordinals do not carry over, and source_boundary is +// provenance, not an index into this stream. +message SessionRecovered { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string source_session_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // The last source-stream ordinal the salvage drew from. + SessionOrdinal source_boundary = 3 [features.field_presence = LEGACY_REQUIRED]; + // Digest of the source cut, over the source's stored bytes. Binds this + // session to exactly what was read, so a later salvage of the same source can + // be told apart from a retry of this one. + Digest source_digest = 4 [features.field_presence = LEGACY_REQUIRED]; + // The salvage operation that produced this session, so the record holding the + // enumerated omissions can be found from the session alone. + string salvage_key = 5 [features.field_presence = LEGACY_REQUIRED]; + RecoveryCompleteness completeness = 6 [features.field_presence = LEGACY_REQUIRED]; + // How many source items could not be carried. The enumeration lives in the + // salvage record; the count lives here because a fold of this stream must be + // able to conclude the session is incomplete without an operator-side lookup + // that may not be available. + uint32 omitted_count = 7 [features.field_presence = LEGACY_REQUIRED]; +} + +// RecoveryCompleteness is how much of the source this session carries. +enum RecoveryCompleteness { + RECOVERY_COMPLETENESS_UNSPECIFIED = 0; + // Every source event decoded and every referenced artifact verified. + RECOVERY_COMPLETENESS_COMPLETE = 1; + // Items are missing. A reader must not present this session as the original. + RECOVERY_COMPLETENESS_PARTIAL = 2; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/start_assistant_message.proto b/proto/trogonai/session/sessions/v1alpha1/start_assistant_message.proto new file mode 100644 index 0000000000..9a3ba70803 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/start_assistant_message.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/model_settings.proto"; + +// StartAssistantMessage opens an assistant turn, recording +// [AssistantMessageStarted]. Streamed token deltas are delivered out of band +// and never appended per token. +// +// Write precondition Any. +message StartAssistantMessage { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string message_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Carried so a replay reproduces the request that was made, not the + // request today's defaults would produce. + string model = 3 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 4 [features.field_presence = LEGACY_REQUIRED]; + // Unset when every setting was left at the provider default. + ModelSettings settings = 5; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/start_execution_attempt.proto b/proto/trogonai/session/sessions/v1alpha1/start_execution_attempt.proto new file mode 100644 index 0000000000..28788b90d5 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/start_execution_attempt.proto @@ -0,0 +1,32 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "google/protobuf/timestamp.proto"; +import "trogonai/session/sessions/v1alpha1/checkpoint.proto"; +import "trogonai/session/sessions/v1alpha1/digest.proto"; + +// StartExecutionAttempt claims the session for a runner, recording +// [ExecutionAttemptStarted]. +// +// Write precondition At: one active attempt at a time, monotonic attempt +// numbers, and a restored checkpoint that exactly equals the first admitted +// evidence for its id with no later redaction or erasure reaching at or before +// its covers_through (ADR#0035 harness recovery). +message StartExecutionAttempt { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string execution_attempt_id = 2 [features.field_presence = LEGACY_REQUIRED]; + // Must equal the session's stored plan digest; a mismatch means the runner + // is about to execute a different plan than the session was started with. + Digest session_execution_plan_digest = 3 [features.field_presence = LEGACY_REQUIRED]; + uint64 attempt_number = 4 [features.field_presence = LEGACY_REQUIRED]; + string previous_attempt_id = 5; + // Unset when the attempt starts from scratch rather than restoring. + Checkpoint restored_checkpoint = 6; + string host_artifact_ref = 7 [features.field_presence = LEGACY_REQUIRED]; + Digest host_artifact_digest = 8 [features.field_presence = LEGACY_REQUIRED]; + string authenticated_remote_subject = 9; + string isolation_placement = 10; + // Supplied by the caller: deciding is deterministic and reads no clock. + google.protobuf.Timestamp started_at = 11 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/start_tool_call.proto b/proto/trogonai/session/sessions/v1alpha1/start_tool_call.proto new file mode 100644 index 0000000000..ae303833f6 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/start_tool_call.proto @@ -0,0 +1,16 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// StartToolCall records that execution began, recording [ToolCallStarted]. +// +// Write precondition Any. This is the fact a crash strands: a started call with +// no terminal outcome is exactly what replay must expose so reconciliation can +// finish or reject it. A start whose tool_call_id matches no request folds as +// unjoined and is flagged, never refused (ADR#0035 orphan happened-fact rule). +message StartToolCall { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string tool_call_id = 2 [features.field_presence = LEGACY_REQUIRED]; + string tool_execution_id = 3 [features.field_presence = LEGACY_REQUIRED]; + string turn_id = 4 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/target_outcome.proto b/proto/trogonai/session/sessions/v1alpha1/target_outcome.proto new file mode 100644 index 0000000000..97a6523ff1 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/target_outcome.proto @@ -0,0 +1,60 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// TargetOutcome records one target a multi-resource tool call failed to apply. +// +// A batch edit over ten files that succeeds for eight and fails for two is not a +// failure. Eight files really changed, and those changes exist independently of +// how the call is labelled: they are FileChanged facts on the log and no result +// status can retract them. Such a call is therefore a ToolCallCompleted with +// result status TOOL_CALL_RESULT_STATUS_APPLICATION_ERROR, never a +// ToolCallFailed, which means nothing was applied at all. +// +// Only failures are recorded here. The successes are already durable as +// FileChanged, and recording them a second time would create two facts for one +// change that can disagree after a rewind or a redaction masks one of them. What +// no other event can express is the negative: that a target was named, attempted, +// and did not happen. Without it a reader sees eight changes for a ten-file +// request and has to infer the gap by comparing against tool arguments, which is +// exactly the inference a typed record exists to make unnecessary. +message TargetOutcome { + // The target as addressed by the call, in the same URI form as + // WorkspaceRef.uri. A URI rather than a workspace-relative path because a + // multi-resource tool's targets are not always files, and a failure against an + // MCP resource or a remote endpoint has no path to record. + string target_uri = 1 [features.field_presence = LEGACY_REQUIRED]; + TargetFailureReason reason = 2 [features.field_presence = LEGACY_REQUIRED]; + // Detail from the tool, for humans. Never parsed. + string detail = 3; +} + +// TargetFailureReason is why one target of a multi-target call did not apply. +// +// Typed because the reasons carry different meanings for whether retrying is +// sound. A permission fault is durable and a retry repeats it; a stale +// precondition means the resource moved under the agent and a retry against +// fresh content may well succeed; a not-attempted target failed for no reason of +// its own at all. +enum TargetFailureReason { + TARGET_FAILURE_REASON_UNSPECIFIED = 0; + // The target did not exist. + TARGET_FAILURE_REASON_NOT_FOUND = 1; + // Access was refused by the underlying system. + TARGET_FAILURE_REASON_PERMISSION_DENIED = 2; + // The target's content no longer matched what the change was decided against, + // which is the ResourceObservation digest that justified the write. + TARGET_FAILURE_REASON_PRECONDITION_FAILED = 3; + // The requested edit did not match anything in the target. + TARGET_FAILURE_REASON_NO_MATCH = 4; + // The edit matched ambiguously and was refused rather than guessed at. + TARGET_FAILURE_REASON_AMBIGUOUS_MATCH = 5; + // The target could not be interpreted in the form the tool required. + TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT = 6; + // The call stopped before reaching this target. It is not a failure of the + // target and says nothing about whether it would have succeeded; recorded so a + // reader never concludes an unreached target was rejected. + TARGET_FAILURE_REASON_NOT_ATTEMPTED = 7; + // The underlying system failed in a way the tool could not classify. + TARGET_FAILURE_REASON_IO_ERROR = 8; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/tool_call_completed.proto b/proto/trogonai/session/sessions/v1alpha1/tool_call_completed.proto index 7fa3652515..3d1da2a1ab 100644 --- a/proto/trogonai/session/sessions/v1alpha1/tool_call_completed.proto +++ b/proto/trogonai/session/sessions/v1alpha1/tool_call_completed.proto @@ -3,8 +3,12 @@ edition = "2024"; package trogonai.session.sessions.v1alpha1; import "google/protobuf/duration.proto"; +import "trogonai/session/sessions/v1alpha1/command_output_replay.proto"; import "trogonai/session/sessions/v1alpha1/command_termination.proto"; +import "trogonai/session/sessions/v1alpha1/detached_work.proto"; +import "trogonai/session/sessions/v1alpha1/resource_access.proto"; import "trogonai/session/sessions/v1alpha1/resource_observation.proto"; +import "trogonai/session/sessions/v1alpha1/target_outcome.proto"; import "trogonai/session/sessions/v1alpha1/tool_call.proto"; // ToolCallCompleted records that a tool call finished successfully. Per @@ -32,4 +36,36 @@ message ToolCallCompleted { // Resources this call put into the model's context, with the digest each // hashed to when it was read. Empty for a call that observed nothing. repeated ResourceObservation observed = 8; + // Claim-check to this command's captured stdout and stderr, for a tool that + // executes a process and captured it; unset otherwise, including for a + // command that ran with capture disabled. + // + // It sits here beside `termination` and not inside `result` for the reason + // `termination` does (D11): captured output is the execution record, while + // `result` is the transcript the model received. They routinely differ, since + // what reaches the model is truncated or summarized, and folding raw output + // into the replay shape would hand a later turn context the original turn + // never had. + CommandOutputReplayRef output_replay = 9; + // Set when this call returned a handle to work that outlived the turn. Unset + // is the ordinary case and means the call's result is its outcome; set means + // the result is a handle and the outcome arrives later through the operation + // ledger. + DetachedWork detached = 10; + // Namespaces this call listed, searched, or otherwise touched, as distinct + // from the content it read. Empty for a call that accessed no namespace. + repeated ResourceAccessRecord accessed = 11; + // Targets of a multi-resource call that did not apply. Empty when every target + // succeeded, and empty is also correct for a single-target call, which has + // nothing partial to report. + // + // Successes are deliberately absent: they are already FileChanged facts, and a + // second record of the same change is a second thing to keep consistent + // through rewind and redaction. + repeated TargetOutcome failed_targets = 12; + // How many targets the call set out to apply, recorded so failed_targets can + // be read as a fraction. Zero for a call with no target list, which is not the + // same as a call that attempted zero targets and is why the count is here + // rather than inferred from an empty list. + uint32 targets_attempted = 13; } diff --git a/proto/trogonai/session/sessions/v1alpha1/unarchive_session.proto b/proto/trogonai/session/sessions/v1alpha1/unarchive_session.proto new file mode 100644 index 0000000000..b09c0d7e7a --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/unarchive_session.proto @@ -0,0 +1,11 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +// UnarchiveSession restores an archived session to the default listing view, +// recording [SessionUnarchived]. +// +// Write precondition Any. +message UnarchiveSession { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/update_todo.proto b/proto/trogonai/session/sessions/v1alpha1/update_todo.proto new file mode 100644 index 0000000000..e1af4c708d --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/update_todo.proto @@ -0,0 +1,21 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/todo_updated.proto"; + +// UpdateTodo replaces the agent's task list wholesale, recording +// [TodoUpdated], so the plan is a domain fact rather than something a +// projection parses out of a tool call's input. +// +// Write precondition Any: the fold keeps the highest revision, which is +// order-independent and so genuinely commuting; ties resolve to the first in +// fold order. +message UpdateTodo { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The complete list as of this update; readers replace, not merge. + repeated TodoItem items = 2; + // Monotonic per session from the single logical writer, the active + // attempt's loop. + uint64 revision = 3 [features.field_presence = LEGACY_REQUIRED]; +} diff --git a/proto/trogonai/session/sessions/v1alpha1/write_outcome.proto b/proto/trogonai/session/sessions/v1alpha1/write_outcome.proto new file mode 100644 index 0000000000..05bccf4c44 --- /dev/null +++ b/proto/trogonai/session/sessions/v1alpha1/write_outcome.proto @@ -0,0 +1,137 @@ +edition = "2024"; + +package trogonai.session.sessions.v1alpha1; + +import "trogonai/session/sessions/v1alpha1/session_ordinal.proto"; + +// WriteOutcome is what a caller learned about its own append. +// +// Every command response carries one. It exists because the interesting +// failures of an append are not "it failed": they are the states between +// success and failure that a boolean cannot express, and that a caller must +// distinguish before it can decide whether retrying is safe. +// +// The reference case is the one this contract is named for. The store accepts +// an event and the acknowledgment is lost. The caller knows only that it +// published. It must not report failure, because the event may be committed. +// It must not blindly retry into a second copy either. It has to be told the +// outcome is unknown, and then be able to resolve it. +// +// There is deliberately no second field naming what the caller should do. +// Disposition is derived from `state`, because two fields for one fact can +// disagree, and the one that disagrees is the one a caller trusted. +message WriteOutcome { + WriteState state = 1 [features.field_presence = LEGACY_REQUIRED]; + // Where the write landed. Present for COMMITTED and DEDUPLICATED, and absent + // for every other state, including UNKNOWN: a position reported for a write + // nobody confirmed is the exact fiction this message exists to prevent. + SessionOrdinal ordinal = 2; + // Present when and only when state is UNKNOWN. + IndeterminateWrite indeterminate = 3; + // Present when and only when state is CONFLICT. + WriteConflict conflict = 4; +} + +// WriteState is what happened to the append, from the caller's vantage point. +enum WriteState { + WRITE_STATE_UNSPECIFIED = 0; + // Definitely not appended. The store rejected the publish before it could + // reach the log, or refused it outright. Retrying is safe. + WRITE_STATE_NOT_APPENDED = 1; + // Appended and acknowledged. `ordinal` names where. + WRITE_STATE_COMMITTED = 2; + // The identical event was already committed and this append was recognized + // as a repeat of it. This is a success, not a failure: it is what a correct + // retry of a lost acknowledgment looks like, and `ordinal` names where the + // original landed. + // + // Distinguished from COMMITTED rather than folded into it because the two + // mean different things to anything counting side effects. A caller that + // notifies on every commit would notify twice. + WRITE_STATE_DEDUPLICATED = 3; + // The append was refused because something about the stream disagreed with + // what the writer believed. Retrying the same command unchanged will fail + // the same way; the writer must re-read and decide again. + WRITE_STATE_CONFLICT = 4; + // The append outcome is unknown. The event may or may not be committed, and + // nothing observed so far decides it. This is not a failure and must not be + // reported as one. + WRITE_STATE_UNKNOWN = 5; +} + +// IndeterminateWrite is why an outcome could not be determined. +// +// The reasons are separated because they are resolved differently, and merging +// them would make a condition that resolves itself on retry indistinguishable +// from one that never will. +message IndeterminateWrite { + UnknownWriteReason reason = 1 [features.field_presence = LEGACY_REQUIRED]; + // Human-readable, non-contractual. Never parse it. + string detail = 2; +} + +// UnknownWriteReason is what prevented the outcome from being determined. +enum UnknownWriteReason { + UNKNOWN_WRITE_REASON_UNSPECIFIED = 0; + // The event was published and no acknowledgment was observed within the + // caller's deadline. The canonical case, and the recoverable one: the + // deterministic event identity makes a retry either commit or deduplicate. + UNKNOWN_WRITE_REASON_ACK_TIMEOUT = 1; + // An acknowledgment arrived and could not be interpreted. Distinct from a + // timeout because the store demonstrably responded, so a transport-level + // retry is answering a different question than a store-level one. + UNKNOWN_WRITE_REASON_ACK_UNREADABLE = 2; + // A multi-event batch acknowledged some members and not others. The stream + // may now hold a partial batch, which no fold expects, so this resolves by + // reading the stream rather than by retrying the batch. + UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED = 3; + // The retry arrived after the store's duplicate-detection window elapsed, so + // the store can no longer tell a repeat from a first attempt. The window is a + // provisioning knob with a bounded lifetime, not a delivery guarantee. + // + // Past it, deduplication moves rather than disappearing: a guarded command + // re-replays and no-ops on its idempotency key at the aggregate, and an + // unguarded fact relies on readers collapsing identical ids. So this reason + // says the outcome is determinable and not determinable from here, which is + // why it is distinct from ACK_TIMEOUT: it points at a different resolver + // rather than at a retry the store can no longer make safe. + UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED = 4; +} + +// WriteConflict is what the writer believed that the stream did not. +message WriteConflict { + ConflictKind kind = 1 [features.field_presence = LEGACY_REQUIRED]; + // The head the writer guarded against. Absent when the writer guarded + // against an empty stream. + SessionOrdinal expected_head = 2; + // The head the stream actually had. Absent when it could not be read, which + // is itself informative: the conflict is real and its shape is not known. + SessionOrdinal observed_head = 3; + // Human-readable, non-contractual. Never parse it. + string detail = 4; +} + +// ConflictKind is which disagreement refused the append. +enum ConflictKind { + CONFLICT_KIND_UNSPECIFIED = 0; + // Optimistic concurrency: the head moved between the read and the append. + // The ordinary contended case, and the only one that is not a defect. + CONFLICT_KIND_WRONG_EXPECTED_HEAD = 1; + // A creation batch guarded against an empty stream and found one that is + // not. The identity is already in use. + CONFLICT_KIND_STREAM_ALREADY_EXISTS = 2; + // An event carrying an already-committed identity did not match the + // committed content. + // + // Event identity is derived in part from a caller-supplied idempotency key, + // so a caller that reuses one key across two different commands produces + // exactly this. It is reported rather than deduplicated because the store's + // duplicate detection keys on identity alone: left to itself it would + // discard the divergent content and acknowledge success, which is silent + // data loss wearing the shape of idempotency. + CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT = 3; + // The subject the writer resolved belongs to a retired stream incarnation + // and no longer accepts writes (ADR#0059). The writer must re-resolve rather + // than retry, because a sealed incarnation refuses every retry forever. + CONFLICT_KIND_INCARNATION_RETIRED = 4; +} diff --git a/proto/trogonai/usage/settlement/v1alpha1/ledger.proto b/proto/trogonai/usage/settlement/v1alpha1/ledger.proto new file mode 100644 index 0000000000..97db7d7608 --- /dev/null +++ b/proto/trogonai/usage/settlement/v1alpha1/ledger.proto @@ -0,0 +1,192 @@ +edition = "2024"; + +package trogonai.usage.settlement.v1alpha1; + +import "google/protobuf/timestamp.proto"; + +// The settlement ledger a downstream billing consumer keeps for itself. +// +// This lives outside the Session domain on purpose. Session records what was +// consumed; a billing consumer reads that and turns it into charges, and the +// retry state of that second job is the consumer's problem, not the session's. +// Publishing settlement progress back into a session stream would put a +// downstream system's bookkeeping into a log that is never truncated +// (ADR#0035 facet 7), so a transient provider outage would leave permanent +// noise in the history of every session it touched. +// +// The one thing this ledger exists for is the case where a charge is published +// and the acknowledgment is lost. At that moment the consumer knows less than +// it did before it tried, and the only safe record is one that says so. Every +// design choice here follows from refusing to let that state be written as +// either success or failure. + +// UsageRef identifies the usage a settlement is for. +// +// It points at the event that recorded consumption, not at a running total. +// Totals are derived and can be recomputed differently; the fact that a +// specific ordinal recorded a specific quantity cannot change, which is what +// makes it usable as an idempotency basis. +message UsageRef { + string session_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The SessionOrdinal that recorded the consumption. + uint64 ordinal = 2 [features.field_presence = LEGACY_REQUIRED]; + // Which meter this is: a model's input tokens, its output tokens, a tool's + // invocations. Opaque to this contract. + string meter = 3 [features.field_presence = LEGACY_REQUIRED]; + uint64 quantity = 4 [features.field_presence = LEGACY_REQUIRED]; + // Who is charged. Carried on the record rather than resolved at settlement + // time, because an account can be reassigned between consumption and billing + // and the charge belongs to whoever owned the work when it ran. + string account_id = 5 [features.field_presence = LEGACY_REQUIRED]; +} + +// SettlementRecord is one usage fact and everything known about charging for it. +// +// The record is written before the charge is published, never after. A ledger +// written after a successful publish cannot describe the failure it exists to +// describe: if the process dies between publishing and recording, the only +// evidence that a charge might exist is gone. +message SettlementRecord { + // Idempotency key and primary identity, derived deterministically from + // `usage`. + // + // Derived from the usage fact and never from the attempt. This is the single + // property that makes double charging impossible rather than unlikely: a + // retry recomputes the same key from the same session, ordinal, and meter, + // so the provider sees the same request it may already have processed. A key + // minted per attempt would make every retry a new charge, and the retry path + // is exactly the path a lost acknowledgment forces a consumer down. + string settlement_id = 1 [features.field_presence = LEGACY_REQUIRED]; + UsageRef usage = 2 [features.field_presence = LEGACY_REQUIRED]; + SettlementState state = 3 [features.field_presence = LEGACY_REQUIRED]; + // Publish attempts made. Counts attempts, not charges: the whole point of a + // stable idempotency key is that these two numbers are allowed to differ. + uint32 attempt_count = 4 [features.field_presence = LEGACY_REQUIRED]; + // When the consumer durably recorded its intent to charge. + google.protobuf.Timestamp intended_at = 5 [features.field_presence = LEGACY_REQUIRED]; + // When the most recent publish was attempted. Unset before the first attempt. + google.protobuf.Timestamp last_attempt_at = 6; + // When a terminal state was reached. Unset while unresolved. + google.protobuf.Timestamp resolved_at = 7; + // What the provider returned, once it returned anything. Unset for every + // state that never heard back, which is the same set of states that need + // reconciling. + ProviderReceipt receipt = 8; + // Set when this settlement needed a human. Its presence is what distinguishes + // a resolution someone decided from one the protocol reached on its own. + SettlementIncident incident = 9; +} + +// SettlementState is how far a settlement got, and what a retry is allowed to +// assume. +// +// The zero value is the one that blocks a blind retry, because the failure mode +// this ledger prevents is a retry that assumes nothing happened. A reader that +// does not recognize a variant must reconcile before charging again. +enum SettlementState { + // Unknown state. Treat as UNKNOWN: reconcile before any further publish. + SETTLEMENT_STATE_UNSPECIFIED = 0; + // Intent is durable and no publish has been attempted. + // + // The only state that lets a consumer conclude no charge exists. It holds + // because the transition to IN_FLIGHT is itself durable and happens before + // the publish call, so a crash cannot skip past it. + SETTLEMENT_STATE_INTENDED = 1; + // A publish is in progress. + // + // Not durable across a restart in the sense a reader might expect: a consumer + // recovering from a crash has no in-progress calls, so every record found in + // this state on startup is moved to UNKNOWN. Its useful life is entirely + // within one process lifetime. + SETTLEMENT_STATE_IN_FLIGHT = 2; + // A publish was attempted and its outcome was never observed. + // + // This is the state the ledger is for. The charge may exist and may not, and + // the consumer must not guess in either direction: republishing under the + // same idempotency key is safe, and treating it as failed and re-deriving a + // key is the double charge. + SETTLEMENT_STATE_UNKNOWN = 3; + // The provider confirmed the charge. Terminal. + SETTLEMENT_STATE_SETTLED = 4; + // The provider refused the charge and said so. Terminal, and not a retry: + // a refusal that is republished unchanged is refused again. + SETTLEMENT_STATE_REJECTED = 5; + // Closed without settling, by a decision recorded in `incident`. Terminal. + // + // Reachable only through an incident, so nothing in the automated path can + // reach it. A consumer that could abandon a charge on its own would be one + // that quietly stops billing under sustained provider failure. + SETTLEMENT_STATE_ABANDONED = 6; +} + +// ProviderReceipt is the provider's own record of a charge. +message ProviderReceipt { + // The provider's identifier for the charge. Kept so a later reconciliation + // can ask about this charge specifically rather than searching by amount and + // time, which is how a reconciliation matches the wrong one. + string provider_charge_id = 1 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp acknowledged_at = 2 [features.field_presence = LEGACY_REQUIRED]; + // True when the provider reported this as a repeat of a charge it had already + // processed under the same idempotency key. + // + // Worth recording rather than discarding as a duplicate-suppressed success: + // it is direct evidence that an earlier attempt landed and its acknowledgment + // was lost, which is the difference between a system that is retrying + // correctly and one that is about to be found out at reconciliation. + bool deduplicated = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// SettlementIncident is a settlement that needed a decision. +message SettlementIncident { + string incident_id = 1 [features.field_presence = LEGACY_REQUIRED]; + IncidentKind kind = 2 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp opened_at = 3 [features.field_presence = LEGACY_REQUIRED]; + // Unset while open. + google.protobuf.Timestamp resolved_at = 4; + IncidentResolution resolution = 5 [features.field_presence = LEGACY_REQUIRED]; + // Free text for whoever has to read this later. Never parsed. + string note = 6 [features.field_presence = LEGACY_REQUIRED]; +} + +// IncidentKind is why a settlement stopped being something the protocol could +// finish by itself. +enum IncidentKind { + INCIDENT_KIND_UNSPECIFIED = 0; + // A settlement sat in UNKNOWN past the window in which the provider could + // still be asked about it. Someone has to establish whether the money moved. + INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED = 1; + // Two settled records were found for the same usage. Either the idempotency + // key was not derived deterministically, or the provider processed the same + // key twice, and both call for a refund rather than a retry. + INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED = 2; + // The provider refused in a way that will not resolve by retrying: a closed + // account, an unrecognized meter, a rejected currency. + INCIDENT_KIND_PROVIDER_REFUSED = 3; + // The session this usage belongs to no longer shows it, because a rewind, + // compaction, or redaction removed the ordinal from effective history. + // + // Opened as an incident rather than reversed automatically, because usage is + // not part of effective history. Tokens that were spent were spent, and + // rewinding a session does not un-consume them, so a ledger that followed + // effective history would refund real compute every time a user backed up a + // turn. What is genuinely ambiguous is whether the removal was a correction + // or a privacy action, and that is a question for a person. + INCIDENT_KIND_USAGE_RETRACTED = 4; +} + +// IncidentResolution is what was decided, once someone decided. +enum IncidentResolution { + // Still open. The zero value, so an incident record that was never resolved + // cannot read as one that was. + INCIDENT_RESOLUTION_UNSPECIFIED = 0; + // Established that the charge exists. The record moves to SETTLED. + INCIDENT_RESOLUTION_CONFIRMED_CHARGED = 1; + // Established that no charge exists. The record returns to INTENDED and may + // be published again. + INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED = 2; + // A charge existed and was reversed. + INCIDENT_RESOLUTION_REFUNDED = 3; + // Closed without charging and without further attempts. The record moves to + // ABANDONED. + INCIDENT_RESOLUTION_WRITTEN_OFF = 4; +} diff --git a/proto/trogonai/usage/settlement/v1alpha1/recovery.proto b/proto/trogonai/usage/settlement/v1alpha1/recovery.proto new file mode 100644 index 0000000000..cf2e7cbb81 --- /dev/null +++ b/proto/trogonai/usage/settlement/v1alpha1/recovery.proto @@ -0,0 +1,142 @@ +edition = "2024"; + +package trogonai.usage.settlement.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "trogonai/usage/settlement/v1alpha1/ledger.proto"; + +// Recovery for a billing consumer: where it got to, and what it left open. + +// ConsumerCheckpoint is how far a billing consumer has read its source. +// +// Consumption position and settlement state are tracked separately, and that +// separation is deliberate. If the watermark could not advance past an +// unresolved settlement, one charge stuck behind a provider outage would stop +// billing for everything after it, and the outage would turn into a backlog +// measured in whatever the busiest tenant produced meanwhile. The watermark +// says what has been turned into ledger records; the ledger says what those +// records came to. +message ConsumerCheckpoint { + string consumer_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // The source this consumer reads. Opaque here; a stream name, a subject, a + // partition. + string source = 2 [features.field_presence = LEGACY_REQUIRED]; + // Position every usage fact below has a durable ledger record for. Advancing + // this before writing those records would lose usage on a crash, which is the + // one failure this ledger cannot detect afterwards: an unrecorded charge + // leaves nothing behind to reconcile against. + uint64 processed_watermark = 3 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp processed_at = 4 [features.field_presence = LEGACY_REQUIRED]; + // Records not in a terminal state. + uint32 open_settlement_count = 5 [features.field_presence = LEGACY_REQUIRED]; + // Records specifically in UNKNOWN. Broken out because it is the number that + // means money may have moved without anyone knowing, and burying it inside a + // general open count is how it stops being looked at. + uint32 unknown_settlement_count = 6 [features.field_presence = LEGACY_REQUIRED]; + // Source position of the oldest open settlement. Unset when nothing is open. + // + // Reported to bound a recovery scan, not to hold the watermark back. It is + // the floor a scan can start from instead of re-reading everything the + // consumer has ever processed. + uint64 oldest_open_watermark = 7; +} + +// ScanOpenSettlementsRequest enumerates settlements that still need attention. +// +// Bounded on purpose. A recovery pass that scans the whole ledger gets slower +// exactly as the system gets busier, so the pass meant to run during an +// incident is the one that stops finishing during an incident. +message ScanOpenSettlementsRequest { + string consumer_id = 1 [features.field_presence = LEGACY_REQUIRED]; + // Which states to return. Empty means every non-terminal state, which is the + // ordinary recovery sweep. + repeated SettlementState states = 2; + // Only records untouched for at least this long. + // + // A settlement published a second ago and not yet acknowledged is not stuck, + // it is in flight, and a recovery pass that republishes it is competing with + // the attempt already running. Unset means no age filter, which is correct + // for a report and wrong for an automated retry loop. + google.protobuf.Duration idle_for = 3; + // Only records at or above this source position. Set from + // `ConsumerCheckpoint.oldest_open_watermark` to make a sweep proportional to + // what is actually open rather than to the ledger's size. + uint64 from_watermark = 4; + uint32 page_size = 5 [features.field_presence = LEGACY_REQUIRED]; + // Opaque continuation. Unset starts a new scan. + bytes page_token = 6; +} + +// ScanOpenSettlementsResponse is one page of unresolved settlements. +message ScanOpenSettlementsResponse { + repeated SettlementRecord records = 1; + // Unset when this is the last page. Presence, and not an empty `records` + // list, is the end signal. + bytes next_page_token = 2; + ScanCoverage coverage = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// ScanCoverage is what the scan did not look at. +// +// Always present, including on a scan that covered everything. An operator +// reading an empty page needs to know whether that means nothing is open or +// the scan ran out of budget, and those two look identical without this. +message ScanCoverage { + bool exhaustive = 1 [features.field_presence = LEGACY_REQUIRED]; + // Source position the scan covered through. + uint64 scanned_through_watermark = 2 [features.field_presence = LEGACY_REQUIRED]; + // Records matching the filter that a fault made unreadable. Non-zero means + // unresolved settlements exist that this scan cannot name, so the sweep must + // not be treated as having cleared anything. + uint32 unreadable_count = 3 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp observed_at = 4 [features.field_presence = LEGACY_REQUIRED]; +} + +// ReconcileSettlementRequest asks the provider what actually happened to a +// settlement whose outcome was never observed. +// +// A query, not a retry. It exists so a consumer facing UNKNOWN has a move other +// than publishing again and hoping the idempotency key holds, and there is no +// field on it that could cause a charge. +message ReconcileSettlementRequest { + string consumer_id = 1 [features.field_presence = LEGACY_REQUIRED]; + string settlement_id = 2 [features.field_presence = LEGACY_REQUIRED]; +} + +// ReconcileSettlementResponse is what the provider says it knows. +message ReconcileSettlementResponse { + ReconciliationOutcome outcome = 1 [features.field_presence = LEGACY_REQUIRED]; + // The updated ledger record, so a caller never has to reconstruct the new + // state from the outcome and hope its transition table matches the server's. + SettlementRecord record = 2 [features.field_presence = LEGACY_REQUIRED]; + google.protobuf.Timestamp observed_at = 3 [features.field_presence = LEGACY_REQUIRED]; +} + +// ReconciliationOutcome is what asking the provider established. +// +// The zero value keeps the settlement unresolved, so a reconciliation that +// returns a variant the caller does not understand leaves the record needing +// attention instead of closing it. +enum ReconciliationOutcome { + // Unknown result. Nothing changes; the record stays unresolved. + RECONCILIATION_OUTCOME_UNSPECIFIED = 0; + // The provider has the charge. The record becomes SETTLED. + RECONCILIATION_OUTCOME_CHARGE_FOUND = 1; + // The provider has no charge under this idempotency key and confirms it + // never processed one. The record becomes INTENDED and may be published. + RECONCILIATION_OUTCOME_CHARGE_ABSENT = 2; + // The provider refused, and says so now. The record becomes REJECTED. + RECONCILIATION_OUTCOME_CHARGE_REFUSED = 3; + // The provider cannot say, usually because the key is older than its + // retention for idempotency records. + // + // Reported rather than folded into ABSENT, because they differ on the only + // question that matters: absent means republishing is safe, and this means + // the provider has forgotten the key that was making it safe. This is what + // opens INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED. + RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY = 4; + // The provider could not be reached. Says nothing about the charge; the + // record stays UNKNOWN and the reconciliation can be tried again. + RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE = 5; +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/mod.rs index 2c55638129..5c39389e59 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/mod.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/mod.rs @@ -437,10 +437,256 @@ pub mod trogonai { clippy::doc_lazy_continuation, clippy::module_inception )] + pub mod artifacts { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.artifacts.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod diff { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.diff.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod doctor { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.doctor.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod maintenance { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.maintenance.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod queries { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.queries.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod replay { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.replay.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod state { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.session.sessions.state.v1alpha1.mod.rs"); + } + } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] pub mod v1alpha1 { use super::*; include!("trogonai.session.sessions.v1alpha1.mod.rs"); } } } + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod usage { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod settlement { + use super::*; + #[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception + )] + pub mod v1alpha1 { + use super::*; + include!("trogonai.usage.settlement.v1alpha1.mod.rs"); + } + } + } } diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.__view.rs new file mode 100644 index 0000000000..70081d05ac --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.__view.rs @@ -0,0 +1,291 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/artifact_error.proto + +/// ArtifactError is the failure shape for the artifact read contract. +/// +/// Only failures to answer belong here. An artifact that is erased, missing, +/// corrupt, or hidden is an answer, carried as ArtifactAvailability on a +/// successful response, because it is a fact about the artifact the caller +/// asked about. Reporting it as an error would make "what happened to this +/// artifact" indistinguishable from "the read contract is broken" at exactly +/// the moment an operator needs to tell them apart. +#[derive(Clone, Debug, Default)] +pub struct ArtifactErrorView<'a> { + /// Field 1: `code` + pub code: ::buffa::EnumValue, + /// Field 2: `message` + pub message: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ArtifactErrorView<'a> { + /**Whether required field `code` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_code(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ArtifactErrorView<'a> { + type Owned = super::super::ArtifactError; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.code = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ArtifactError { + code: self.code, + message: self.message.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ArtifactErrorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ArtifactErrorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("code", &self.code)?; + } + { + __map.serialize_entry("message", self.message)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ArtifactErrorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ArtifactError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ArtifactError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ArtifactError"; +} +::buffa::impl_default_view_instance!(ArtifactErrorView); +::buffa::impl_view_reborrow!(ArtifactErrorView); +/** Self-contained, `'static` owned view of a `ArtifactError` message. + + Wraps [`::buffa::OwnedView`]`<`[`ArtifactErrorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ArtifactErrorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ArtifactErrorOwnedView(::buffa::OwnedView>); +impl ArtifactErrorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactErrorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactErrorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ArtifactError, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactErrorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ArtifactErrorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ArtifactErrorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ArtifactError { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `code` + #[must_use] + pub fn code(&self) -> ::buffa::EnumValue { + self.0.reborrow().code + } + /// Field 2: `message` + #[must_use] + pub fn message(&self) -> &'_ str { + self.0.reborrow().message + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ArtifactErrorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ArtifactErrorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ArtifactErrorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ArtifactErrorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ArtifactError { + type View<'a> = ArtifactErrorView<'a>; + type ViewHandle = ArtifactErrorOwnedView; +} +impl ::serde::Serialize for ArtifactErrorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.rs new file mode 100644 index 0000000000..36b44d7e30 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.artifact_error.rs @@ -0,0 +1,376 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/artifact_error.proto + +/// ArtifactErrorCode is why the request could not be answered. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ArtifactErrorCode { + ARTIFACT_ERROR_CODE_UNSPECIFIED = 0i32, + /// No such session, or the caller may not see it. Deliberately one code, and + /// deliberately not distinguished from permission denial, so that probing + /// cannot use the difference to prove a session exists. + ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND = 1i32, + /// The session exists and holds no artifact under this id. This is not the + /// same as ARTIFACT_AVAILABILITY_MISSING: here the claim-check itself is + /// absent, so nothing was ever promised, whereas MISSING is a promise the log + /// made and the store did not keep. + ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND = 2i32, + /// The range is not addressable: an offset past the end of the artifact, or a + /// zero length. + ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE = 3i32, + /// Verification was required and the artifact has no chunk manifest, so no + /// checkable range of it exists. Refusing here is the whole value of the + /// requirement: the alternative is a caller believing it verified a read + /// because it asked to. + ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE = 4i32, + /// The requested length exceeds what a single response may carry. The bound is + /// deployment-specific, so it is reported rather than encoded in the schema; + /// the message carries the accepted maximum. + ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE = 5i32, + /// Malformed request that is none of the above. + ARTIFACT_ERROR_CODE_INVALID_ARGUMENT = 6i32, +} +impl ArtifactErrorCode { + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ARTIFACT_ERROR_CODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SessionNotFound: Self = Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ArtifactNotFound: Self = Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RangeNotSatisfiable: Self = Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const VerificationUnavailable: Self = Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RangeTooLarge: Self = Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE; + ///Idiomatic alias for [`Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InvalidArgument: Self = Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT; +} +impl ::core::default::Default for ArtifactErrorCode { + fn default() -> Self { + Self::ARTIFACT_ERROR_CODE_UNSPECIFIED + } +} +impl ::serde::Serialize for ArtifactErrorCode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ArtifactErrorCode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ArtifactErrorCode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ArtifactErrorCode) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactErrorCode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ArtifactErrorCode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND) + } + 2i32 => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE, + ) + } + 5i32 => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE) + } + 6i32 => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ARTIFACT_ERROR_CODE_UNSPECIFIED => "ARTIFACT_ERROR_CODE_UNSPECIFIED", + Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND => { + "ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND" + } + Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND => { + "ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND" + } + Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE => { + "ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE" + } + Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE => { + "ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE" + } + Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE => { + "ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE" + } + Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT => { + "ARTIFACT_ERROR_CODE_INVALID_ARGUMENT" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ARTIFACT_ERROR_CODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_UNSPECIFIED) + } + "ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND" => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND) + } + "ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND" => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND, + ) + } + "ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE" => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE, + ) + } + "ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE" => { + ::core::option::Option::Some( + Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE, + ) + } + "ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE" => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE) + } + "ARTIFACT_ERROR_CODE_INVALID_ARGUMENT" => { + ::core::option::Option::Some(Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ARTIFACT_ERROR_CODE_UNSPECIFIED, + Self::ARTIFACT_ERROR_CODE_SESSION_NOT_FOUND, + Self::ARTIFACT_ERROR_CODE_ARTIFACT_NOT_FOUND, + Self::ARTIFACT_ERROR_CODE_RANGE_NOT_SATISFIABLE, + Self::ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE, + Self::ARTIFACT_ERROR_CODE_RANGE_TOO_LARGE, + Self::ARTIFACT_ERROR_CODE_INVALID_ARGUMENT, + ] + } +} +/// ArtifactError is the failure shape for the artifact read contract. +/// +/// Only failures to answer belong here. An artifact that is erased, missing, +/// corrupt, or hidden is an answer, carried as ArtifactAvailability on a +/// successful response, because it is a fact about the artifact the caller +/// asked about. Reporting it as an error would make "what happened to this +/// artifact" indistinguishable from "the read contract is broken" at exactly +/// the moment an operator needs to tell them apart. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ArtifactError { + /// Field 1: `code` + #[serde(rename = "code", with = "::buffa::json_helpers::proto_enum")] + pub code: ::buffa::EnumValue, + /// Field 2: `message` + #[serde(rename = "message", with = "::buffa::json_helpers::proto_string")] + pub message: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for ArtifactError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ArtifactError") + .field("code", &self.code) + .field("message", &self.message) + .finish() + } +} +impl ArtifactError { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ArtifactError"; +} +::buffa::impl_default_instance!(ArtifactError); +impl ::buffa::MessageName for ArtifactError { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ArtifactError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ArtifactError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ArtifactError"; +} +impl ::buffa::Message for ArtifactError { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.code = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.code = ::buffa::EnumValue::from(0); + self.message.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactError { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ARTIFACT_ERROR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ArtifactError", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.availability.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.availability.rs new file mode 100644 index 0000000000..e5371e30ca --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.availability.rs @@ -0,0 +1,258 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/availability.proto + +/// Value types for the Session artifact read contract. +/// +/// These are redefined here rather than imported from the write side on purpose +/// (ADR#0035 facet 3). The write side records what happened to an artifact; this +/// contract answers what a caller can get right now, and the two change for +/// different reasons and on different cadences. +/// +/// ArtifactAvailability is what a caller can expect to read, and why, when the +/// answer is not "the bytes". +/// +/// A claim-check can fail to resolve for reasons that are not interchangeable, +/// and collapsing them into a single "missing" is how deliberate destruction +/// gets reported as data loss and how a transient storage fault gets reported as +/// permanent. Every non-AVAILABLE value here is a distinct operational +/// situation with a distinct correct response. +/// +/// The vocabulary deliberately reuses the Session doctor's +/// mismatch/absent/unreadable distinction rather than inventing a second +/// taxonomy for the same three facts. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ArtifactAvailability { + ARTIFACT_AVAILABILITY_UNSPECIFIED = 0i32, + /// The bytes are readable now. + ARTIFACT_AVAILABILITY_AVAILABLE = 1i32, + /// Destroyed on purpose and recorded as such by ArtifactErased. The + /// claim-check and its provenance remain on the log; the bytes are gone and + /// are not coming back. This is a correct end state, not a fault, and a reader + /// that renders it as damage will send someone looking for a problem that was + /// the point. + ARTIFACT_AVAILABILITY_ERASED = 2i32, + /// The store reports no such object, and no erasure was ever recorded. This is + /// the one value that means something went wrong: the log says bytes exist + /// that do not. + ARTIFACT_AVAILABILITY_MISSING = 3i32, + /// The artifact was recorded as an external reference whose bytes were never + /// durably stored. There is nothing to range-read, and there never was; the + /// source location may or may not still serve them, which is not this + /// contract's claim to make. + ARTIFACT_AVAILABILITY_EXTERNAL_ONLY = 4i32, + /// The object was read and does not match the digest recorded on the log. The + /// bytes exist and are not the artifact's, so serving them silently would hand + /// a caller content under a claim-check it does not satisfy. + ARTIFACT_AVAILABILITY_CORRUPT = 5i32, + /// The object could not be read. Unlike MISSING this makes no claim about + /// whether the bytes exist: a permissions or transport fault against the + /// artifact store looks identical from here, and a retry may succeed. + ARTIFACT_AVAILABILITY_UNREADABLE = 6i32, + /// The caller may see that this artifact exists and may not read it. + /// + /// This is reported, rather than answered as MISSING, only because the caller + /// can already see the claim-check in the session's own history. Hiding the + /// bytes from someone who is looking at the reference protects the content; + /// pretending the reference is dangling would just describe the session + /// incorrectly. An artifact belonging to a session the caller cannot see is + /// never reachable to be labelled at all. + ARTIFACT_AVAILABILITY_HIDDEN = 7i32, +} +impl ArtifactAvailability { + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ARTIFACT_AVAILABILITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_AVAILABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Available: Self = Self::ARTIFACT_AVAILABILITY_AVAILABLE; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_ERASED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Erased: Self = Self::ARTIFACT_AVAILABILITY_ERASED; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Missing: Self = Self::ARTIFACT_AVAILABILITY_MISSING; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ExternalOnly: Self = Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_CORRUPT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Corrupt: Self = Self::ARTIFACT_AVAILABILITY_CORRUPT; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_UNREADABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unreadable: Self = Self::ARTIFACT_AVAILABILITY_UNREADABLE; + ///Idiomatic alias for [`Self::ARTIFACT_AVAILABILITY_HIDDEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Hidden: Self = Self::ARTIFACT_AVAILABILITY_HIDDEN; +} +impl ::core::default::Default for ArtifactAvailability { + fn default() -> Self { + Self::ARTIFACT_AVAILABILITY_UNSPECIFIED + } +} +impl ::serde::Serialize for ArtifactAvailability { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ArtifactAvailability { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ArtifactAvailability; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ArtifactAvailability) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactAvailability { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ArtifactAvailability { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_AVAILABLE), + 2i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_ERASED), + 3i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_MISSING), + 4i32 => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY) + } + 5i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_CORRUPT), + 6i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_UNREADABLE), + 7i32 => ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_HIDDEN), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ARTIFACT_AVAILABILITY_UNSPECIFIED => { + "ARTIFACT_AVAILABILITY_UNSPECIFIED" + } + Self::ARTIFACT_AVAILABILITY_AVAILABLE => "ARTIFACT_AVAILABILITY_AVAILABLE", + Self::ARTIFACT_AVAILABILITY_ERASED => "ARTIFACT_AVAILABILITY_ERASED", + Self::ARTIFACT_AVAILABILITY_MISSING => "ARTIFACT_AVAILABILITY_MISSING", + Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY => { + "ARTIFACT_AVAILABILITY_EXTERNAL_ONLY" + } + Self::ARTIFACT_AVAILABILITY_CORRUPT => "ARTIFACT_AVAILABILITY_CORRUPT", + Self::ARTIFACT_AVAILABILITY_UNREADABLE => "ARTIFACT_AVAILABILITY_UNREADABLE", + Self::ARTIFACT_AVAILABILITY_HIDDEN => "ARTIFACT_AVAILABILITY_HIDDEN", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ARTIFACT_AVAILABILITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_UNSPECIFIED) + } + "ARTIFACT_AVAILABILITY_AVAILABLE" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_AVAILABLE) + } + "ARTIFACT_AVAILABILITY_ERASED" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_ERASED) + } + "ARTIFACT_AVAILABILITY_MISSING" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_MISSING) + } + "ARTIFACT_AVAILABILITY_EXTERNAL_ONLY" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY) + } + "ARTIFACT_AVAILABILITY_CORRUPT" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_CORRUPT) + } + "ARTIFACT_AVAILABILITY_UNREADABLE" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_UNREADABLE) + } + "ARTIFACT_AVAILABILITY_HIDDEN" => { + ::core::option::Option::Some(Self::ARTIFACT_AVAILABILITY_HIDDEN) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ARTIFACT_AVAILABILITY_UNSPECIFIED, + Self::ARTIFACT_AVAILABILITY_AVAILABLE, + Self::ARTIFACT_AVAILABILITY_ERASED, + Self::ARTIFACT_AVAILABILITY_MISSING, + Self::ARTIFACT_AVAILABILITY_EXTERNAL_ONLY, + Self::ARTIFACT_AVAILABILITY_CORRUPT, + Self::ARTIFACT_AVAILABILITY_UNREADABLE, + Self::ARTIFACT_AVAILABILITY_HIDDEN, + ] + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.__view.rs new file mode 100644 index 0000000000..a5f95fecce --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.__view.rs @@ -0,0 +1,705 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/chunk_manifest.proto + +/// GetChunkManifestRequest asks for the per-chunk digests that make ranges of an +/// artifact checkable. +#[derive(Clone, Debug, Default)] +pub struct GetChunkManifestRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `artifact_id` + pub artifact_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetChunkManifestRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for GetChunkManifestRequestView<'a> { + type Owned = super::super::GetChunkManifestRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetChunkManifestRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetChunkManifestRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetChunkManifestRequest { + session_id: self.session_id.to_string(), + artifact_id: self.artifact_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetChunkManifestRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetChunkManifestRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetChunkManifestRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "GetChunkManifestRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest"; +} +::buffa::impl_default_view_instance!(GetChunkManifestRequestView); +::buffa::impl_view_reborrow!(GetChunkManifestRequestView); +/** Self-contained, `'static` owned view of a `GetChunkManifestRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetChunkManifestRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetChunkManifestRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetChunkManifestRequestOwnedView( + ::buffa::OwnedView>, +); +impl GetChunkManifestRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetChunkManifestRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetChunkManifestRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetChunkManifestRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetChunkManifestRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetChunkManifestRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetChunkManifestRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetChunkManifestRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetChunkManifestRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetChunkManifestRequest { + type View<'a> = GetChunkManifestRequestView<'a>; + type ViewHandle = GetChunkManifestRequestOwnedView; +} +impl ::serde::Serialize for GetChunkManifestRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// GetChunkManifestResponse carries the ordered chunk digests. +/// +/// The manifest comes from the artifact store, so on its own it proves nothing: +/// a store serving wrong bytes can serve a manifest that agrees with them. It +/// becomes evidence only when the caller hashes it and compares the result +/// against the manifest digest recorded on the event log, which the store did +/// not supply. A caller that skips that comparison has verified nothing and +/// should say so rather than report a verified read. +#[derive(Clone, Debug, Default)] +pub struct GetChunkManifestResponseView<'a> { + /// Field 1: `artifact_id` + pub artifact_id: &'a str, + /// Hash used for each chunk digest and for the digest over their + /// concatenation, for example "sha256". + /// + /// Field 2: `algorithm` + pub algorithm: &'a str, + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 3: `chunk_size_bytes` + pub chunk_size_bytes: u64, + /// Total size of the artifact, so a caller can tell a complete manifest from a + /// truncated one before trusting any chunk in it. + /// + /// Field 4: `size_bytes` + pub size_bytes: u64, + /// Raw chunk digests in artifact order, one per chunk. The algorithm is on the + /// envelope because every entry uses the same one, and a per-entry algorithm + /// would be a per-entry opportunity for them to disagree. + /// + /// Field 5: `chunk_digests` + pub chunk_digests: ::buffa::RepeatedView<'a, &'a [u8]>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetChunkManifestResponseView<'a> { + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `algorithm` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_algorithm(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `chunk_size_bytes` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_chunk_size_bytes(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `size_bytes` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_size_bytes(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for GetChunkManifestResponseView<'a> { + type Owned = super::super::GetChunkManifestResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.algorithm = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.chunk_size_bytes = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.size_bytes = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + view.chunk_digests.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetChunkManifestResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetChunkManifestResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetChunkManifestResponse { + artifact_id: self.artifact_id.to_string(), + algorithm: self.algorithm.to_string(), + chunk_size_bytes: self.chunk_size_bytes, + size_bytes: self.size_bytes, + chunk_digests: self.chunk_digests.iter().map(|b| (b).to_vec()).collect(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetChunkManifestResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.chunk_size_bytes) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + for v in &self.chunk_digests { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_string_field(2u32, &self.algorithm, buf); + ::buffa::types::put_uint64_field(3u32, self.chunk_size_bytes, buf); + ::buffa::types::put_uint64_field(4u32, self.size_bytes, buf); + for v in &self.chunk_digests { + ::buffa::types::put_shared_bytes_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetChunkManifestResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + { + __map.serialize_entry("algorithm", self.algorithm)?; + } + { + __map + .serialize_entry( + "chunkSizeBytes", + &::buffa::json_helpers::ProtoJson(&self.chunk_size_bytes), + )?; + } + { + __map + .serialize_entry( + "sizeBytes", + &::buffa::json_helpers::ProtoJson(&self.size_bytes), + )?; + } + if !self.chunk_digests.is_empty() { + __map + .serialize_entry( + "chunkDigests", + &::buffa::json_helpers::BytesSeqJson(&self.chunk_digests), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetChunkManifestResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "GetChunkManifestResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse"; +} +::buffa::impl_default_view_instance!(GetChunkManifestResponseView); +::buffa::impl_view_reborrow!(GetChunkManifestResponseView); +/** Self-contained, `'static` owned view of a `GetChunkManifestResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetChunkManifestResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetChunkManifestResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetChunkManifestResponseOwnedView( + ::buffa::OwnedView>, +); +impl GetChunkManifestResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetChunkManifestResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetChunkManifestResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetChunkManifestResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetChunkManifestResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetChunkManifestResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// Hash used for each chunk digest and for the digest over their + /// concatenation, for example "sha256". + /// + /// Field 2: `algorithm` + #[must_use] + pub fn algorithm(&self) -> &'_ str { + self.0.reborrow().algorithm + } + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 3: `chunk_size_bytes` + #[must_use] + pub fn chunk_size_bytes(&self) -> u64 { + self.0.reborrow().chunk_size_bytes + } + /// Total size of the artifact, so a caller can tell a complete manifest from a + /// truncated one before trusting any chunk in it. + /// + /// Field 4: `size_bytes` + #[must_use] + pub fn size_bytes(&self) -> u64 { + self.0.reborrow().size_bytes + } + /// Raw chunk digests in artifact order, one per chunk. The algorithm is on the + /// envelope because every entry uses the same one, and a per-entry algorithm + /// would be a per-entry opportunity for them to disagree. + /// + /// Field 5: `chunk_digests` + #[must_use] + pub fn chunk_digests(&self) -> &::buffa::RepeatedView<'_, &'_ [u8]> { + &self.0.reborrow().chunk_digests + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetChunkManifestResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetChunkManifestResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetChunkManifestResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetChunkManifestResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetChunkManifestResponse { + type View<'a> = GetChunkManifestResponseView<'a>; + type ViewHandle = GetChunkManifestResponseOwnedView; +} +impl ::serde::Serialize for GetChunkManifestResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.rs new file mode 100644 index 0000000000..eeb9bd5ce6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.rs @@ -0,0 +1,332 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/chunk_manifest.proto + +/// GetChunkManifestRequest asks for the per-chunk digests that make ranges of an +/// artifact checkable. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChunkManifestRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for GetChunkManifestRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChunkManifestRequest") + .field("session_id", &self.session_id) + .field("artifact_id", &self.artifact_id) + .finish() + } +} +impl GetChunkManifestRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest"; +} +::buffa::impl_default_instance!(GetChunkManifestRequest); +impl ::buffa::MessageName for GetChunkManifestRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "GetChunkManifestRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest"; +} +impl ::buffa::Message for GetChunkManifestRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.artifact_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetChunkManifestRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHUNK_MANIFEST_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// GetChunkManifestResponse carries the ordered chunk digests. +/// +/// The manifest comes from the artifact store, so on its own it proves nothing: +/// a store serving wrong bytes can serve a manifest that agrees with them. It +/// becomes evidence only when the caller hashes it and compares the result +/// against the manifest digest recorded on the event log, which the store did +/// not supply. A caller that skips that comparison has verified nothing and +/// should say so rather than report a verified read. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChunkManifestResponse { + /// Field 1: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// Hash used for each chunk digest and for the digest over their + /// concatenation, for example "sha256". + /// + /// Field 2: `algorithm` + #[serde(rename = "algorithm", with = "::buffa::json_helpers::proto_string")] + pub algorithm: ::buffa::alloc::string::String, + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 3: `chunk_size_bytes` + #[serde( + rename = "chunkSizeBytes", + alias = "chunk_size_bytes", + with = "::buffa::json_helpers::uint64" + )] + pub chunk_size_bytes: u64, + /// Total size of the artifact, so a caller can tell a complete manifest from a + /// truncated one before trusting any chunk in it. + /// + /// Field 4: `size_bytes` + #[serde( + rename = "sizeBytes", + alias = "size_bytes", + with = "::buffa::json_helpers::uint64" + )] + pub size_bytes: u64, + /// Raw chunk digests in artifact order, one per chunk. The algorithm is on the + /// envelope because every entry uses the same one, and a per-entry algorithm + /// would be a per-entry opportunity for them to disagree. + /// + /// Field 5: `chunk_digests` + #[serde( + rename = "chunkDigests", + alias = "chunk_digests", + with = "::buffa::json_helpers::proto_seq", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec" + )] + pub chunk_digests: ::buffa::alloc::vec::Vec<::buffa::alloc::vec::Vec>, +} +impl ::core::fmt::Debug for GetChunkManifestResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChunkManifestResponse") + .field("artifact_id", &self.artifact_id) + .field("algorithm", &self.algorithm) + .field("chunk_size_bytes", &self.chunk_size_bytes) + .field("size_bytes", &self.size_bytes) + .field("chunk_digests", &self.chunk_digests) + .finish() + } +} +impl GetChunkManifestResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse"; +} +::buffa::impl_default_instance!(GetChunkManifestResponse); +impl ::buffa::MessageName for GetChunkManifestResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "GetChunkManifestResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse"; +} +impl ::buffa::Message for GetChunkManifestResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.chunk_size_bytes) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + for v in &self.chunk_digests { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_string_field(2u32, &self.algorithm, buf); + ::buffa::types::put_uint64_field(3u32, self.chunk_size_bytes, buf); + ::buffa::types::put_uint64_field(4u32, self.size_bytes, buf); + for v in &self.chunk_digests { + ::buffa::types::put_shared_bytes_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.algorithm, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.chunk_size_bytes = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.size_bytes = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_bytes(buf)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + self.chunk_digests.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.artifact_id.clear(); + self.algorithm.clear(); + self.chunk_size_bytes = 0u64; + self.size_bytes = 0u64; + self.chunk_digests.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetChunkManifestResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHUNK_MANIFEST_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.GetChunkManifestResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.mod.rs new file mode 100644 index 0000000000..404cd0c93b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.mod.rs @@ -0,0 +1,81 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.artifacts.v1alpha1.artifact_error.rs"); +include!("trogonai.session.sessions.artifacts.v1alpha1.availability.rs"); +include!("trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.rs"); +include!("trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.rs"); +include!("trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!( + "trogonai.session.sessions.artifacts.v1alpha1.artifact_error.__view.rs" + ); + include!( + "trogonai.session.sessions.artifacts.v1alpha1.chunk_manifest.__view.rs" + ); + include!( + "trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.__view.rs" + ); + include!("trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.__view.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__ARTIFACT_ERROR_JSON_ANY); + reg.register_json_any(super::__GET_CHUNK_MANIFEST_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_CHUNK_MANIFEST_RESPONSE_JSON_ANY); + reg.register_json_any(super::__READ_ARTIFACT_RANGE_REQUEST_JSON_ANY); + reg.register_json_any(super::__READ_ARTIFACT_RANGE_RESPONSE_JSON_ANY); + reg.register_json_any(super::__STAT_ARTIFACT_REQUEST_JSON_ANY); + reg.register_json_any(super::__STAT_ARTIFACT_RESPONSE_JSON_ANY); + reg.register_json_any(super::__READABLE_CONTENT_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::ArtifactErrorView; +#[doc(inline)] +pub use self::__buffa::view::ArtifactErrorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetChunkManifestRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetChunkManifestRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetChunkManifestResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetChunkManifestResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReadArtifactRangeRequestView; +#[doc(inline)] +pub use self::__buffa::view::ReadArtifactRangeRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReadArtifactRangeResponseView; +#[doc(inline)] +pub use self::__buffa::view::ReadArtifactRangeResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StatArtifactRequestView; +#[doc(inline)] +pub use self::__buffa::view::StatArtifactRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StatArtifactResponseView; +#[doc(inline)] +pub use self::__buffa::view::StatArtifactResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReadableContentView; +#[doc(inline)] +pub use self::__buffa::view::ReadableContentOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.__view.rs new file mode 100644 index 0000000000..c72f8aa563 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.__view.rs @@ -0,0 +1,929 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/read_artifact_range.proto + +/// ReadArtifactRangeRequest asks for a bounded window of an artifact's bytes. +/// +/// There is no request for the whole artifact and no way to express one. A +/// caller that wants all 40 MB issues successive ranges; the transport carries +/// JSON-RPC bodies over NATS (ADR#0055, ADR#0056) and has no streaming call, so +/// successive bounded reads are the streaming primitive rather than a +/// workaround for the absence of one. The practical difference is that the +/// bound is always the caller's and always visible, instead of a limit +/// discovered when a response fails to fit. +#[derive(Clone, Debug, Default)] +pub struct ReadArtifactRangeRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `artifact_id` + pub artifact_id: &'a str, + /// First byte requested, counted from the start of the artifact. + /// + /// Field 3: `offset` + pub offset: u64, + /// How many bytes are wanted. The server may serve fewer at the end of the + /// artifact or under its own cap, and may serve more only to reach a chunk + /// boundary when verification was required. What was served is on the + /// response; a caller must read it rather than assume it got what it asked + /// for. + /// + /// Field 4: `length` + pub length: u64, + /// Field 5: `verification` + pub verification: ::core::option::Option< + ::buffa::EnumValue, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReadArtifactRangeRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `offset` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_offset(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `length` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_length(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReadArtifactRangeRequestView<'a> { + type Owned = super::super::ReadArtifactRangeRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.offset = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.length = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.verification = Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(&mut cur)?), + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReadArtifactRangeRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReadArtifactRangeRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReadArtifactRangeRequest { + session_id: self.session_id.to_string(), + artifact_id: self.artifact_id.to_string(), + offset: self.offset, + length: self.length, + verification: self.verification, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReadArtifactRangeRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.length) as u64; + if let Some(ref v) = self.verification { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + ::buffa::types::put_uint64_field(3u32, self.offset, buf); + ::buffa::types::put_uint64_field(4u32, self.length, buf); + if let Some(ref v) = self.verification { + ::buffa::types::put_int32_field(5u32, v.to_i32(), buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReadArtifactRangeRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + { + __map + .serialize_entry( + "offset", + &::buffa::json_helpers::ProtoJson(&self.offset), + )?; + } + { + __map + .serialize_entry( + "length", + &::buffa::json_helpers::ProtoJson(&self.length), + )?; + } + if let ::core::option::Option::Some(ref __v) = self.verification { + __map.serialize_entry("verification", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReadArtifactRangeRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadArtifactRangeRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest"; +} +::buffa::impl_default_view_instance!(ReadArtifactRangeRequestView); +::buffa::impl_view_reborrow!(ReadArtifactRangeRequestView); +/** Self-contained, `'static` owned view of a `ReadArtifactRangeRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReadArtifactRangeRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReadArtifactRangeRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReadArtifactRangeRequestOwnedView( + ::buffa::OwnedView>, +); +impl ReadArtifactRangeRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReadArtifactRangeRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReadArtifactRangeRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReadArtifactRangeRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReadArtifactRangeRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// First byte requested, counted from the start of the artifact. + /// + /// Field 3: `offset` + #[must_use] + pub fn offset(&self) -> u64 { + self.0.reborrow().offset + } + /// How many bytes are wanted. The server may serve fewer at the end of the + /// artifact or under its own cap, and may serve more only to reach a chunk + /// boundary when verification was required. What was served is on the + /// response; a caller must read it rather than assume it got what it asked + /// for. + /// + /// Field 4: `length` + #[must_use] + pub fn length(&self) -> u64 { + self.0.reborrow().length + } + /// Field 5: `verification` + #[must_use] + pub fn verification( + &self, + ) -> ::core::option::Option< + ::buffa::EnumValue, + > { + self.0.reborrow().verification + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReadArtifactRangeRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReadArtifactRangeRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReadArtifactRangeRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReadArtifactRangeRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReadArtifactRangeRequest { + type View<'a> = ReadArtifactRangeRequestView<'a>; + type ViewHandle = ReadArtifactRangeRequestOwnedView; +} +impl ::serde::Serialize for ReadArtifactRangeRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReadArtifactRangeResponse carries the served bytes and says what they are +/// worth. +#[derive(Clone, Debug, Default)] +pub struct ReadArtifactRangeResponseView<'a> { + /// Field 1: `artifact_id` + pub artifact_id: &'a str, + /// Field 2: `availability` + pub availability: ::buffa::EnumValue, + /// First byte actually served. Equal to the requested offset unless + /// verification required aligning down to a chunk boundary. + /// + /// Field 3: `offset` + pub offset: u64, + /// The served bytes. Empty for every availability except + /// ARTIFACT_AVAILABILITY_AVAILABLE. Its length is the served length; a + /// separate length field would be a second copy of a fact the bytes already + /// carry, and the copy is what a caller would trust when they disagree. + /// + /// Field 4: `content` + pub content: ::core::option::Option<&'a [u8]>, + /// Total size of the artifact. This is what makes the response + /// self-describing: with the served offset and length, a caller derives + /// reaching the end of the artifact from being cut short by the server + /// without a flag that could contradict the numbers next to it, and knows + /// where to resume without a second call. + /// + /// Field 5: `size_bytes` + pub size_bytes: u64, + /// Field 6: `verifiability` + pub verifiability: ::buffa::EnumValue, + /// Field 7: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReadArtifactRangeResponseView<'a> { + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `availability` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_availability(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `offset` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_offset(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `size_bytes` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_size_bytes(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `verifiability` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_verifiability(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ReadArtifactRangeResponseView<'a> { + type Owned = super::super::ReadArtifactRangeResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.offset = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.content = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.size_bytes = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.verifiability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReadArtifactRangeResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReadArtifactRangeResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReadArtifactRangeResponse { + artifact_id: self.artifact_id.to_string(), + availability: self.availability, + offset: self.offset, + content: self.content.map(|b| (b).to_vec()), + size_bytes: self.size_bytes, + verifiability: self.verifiability, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReadArtifactRangeResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.offset) as u64; + if let Some(ref v) = self.content { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + { + let val = self.verifiability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + ::buffa::types::put_uint64_field(3u32, self.offset, buf); + if let Some(ref v) = self.content { + ::buffa::types::put_shared_bytes_field(4u32, v, buf); + } + ::buffa::types::put_uint64_field(5u32, self.size_bytes, buf); + ::buffa::types::put_int32_field(6u32, self.verifiability.to_i32(), buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReadArtifactRangeResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + { + __map.serialize_entry("availability", &self.availability)?; + } + { + __map + .serialize_entry( + "offset", + &::buffa::json_helpers::ProtoJson(&self.offset), + )?; + } + if let ::core::option::Option::Some(__v) = self.content { + __map.serialize_entry("content", &::buffa::json_helpers::BytesJson(__v))?; + } + { + __map + .serialize_entry( + "sizeBytes", + &::buffa::json_helpers::ProtoJson(&self.size_bytes), + )?; + } + { + __map.serialize_entry("verifiability", &self.verifiability)?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReadArtifactRangeResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadArtifactRangeResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse"; +} +::buffa::impl_default_view_instance!(ReadArtifactRangeResponseView); +::buffa::impl_view_reborrow!(ReadArtifactRangeResponseView); +/** Self-contained, `'static` owned view of a `ReadArtifactRangeResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReadArtifactRangeResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReadArtifactRangeResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReadArtifactRangeResponseOwnedView( + ::buffa::OwnedView>, +); +impl ReadArtifactRangeResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReadArtifactRangeResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadArtifactRangeResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReadArtifactRangeResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReadArtifactRangeResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReadArtifactRangeResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// Field 2: `availability` + #[must_use] + pub fn availability( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().availability + } + /// First byte actually served. Equal to the requested offset unless + /// verification required aligning down to a chunk boundary. + /// + /// Field 3: `offset` + #[must_use] + pub fn offset(&self) -> u64 { + self.0.reborrow().offset + } + /// The served bytes. Empty for every availability except + /// ARTIFACT_AVAILABILITY_AVAILABLE. Its length is the served length; a + /// separate length field would be a second copy of a fact the bytes already + /// carry, and the copy is what a caller would trust when they disagree. + /// + /// Field 4: `content` + #[must_use] + pub fn content(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().content + } + /// Total size of the artifact. This is what makes the response + /// self-describing: with the served offset and length, a caller derives + /// reaching the end of the artifact from being cut short by the server + /// without a flag that could contradict the numbers next to it, and knows + /// where to resume without a second call. + /// + /// Field 5: `size_bytes` + #[must_use] + pub fn size_bytes(&self) -> u64 { + self.0.reborrow().size_bytes + } + /// Field 6: `verifiability` + #[must_use] + pub fn verifiability(&self) -> ::buffa::EnumValue { + self.0.reborrow().verifiability + } + /// Field 7: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReadArtifactRangeResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReadArtifactRangeResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReadArtifactRangeResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReadArtifactRangeResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReadArtifactRangeResponse { + type View<'a> = ReadArtifactRangeResponseView<'a>; + type ViewHandle = ReadArtifactRangeResponseOwnedView; +} +impl ::serde::Serialize for ReadArtifactRangeResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.rs new file mode 100644 index 0000000000..4e23391602 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.read_artifact_range.rs @@ -0,0 +1,834 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/read_artifact_range.proto + +/// VerificationRequirement is whether the caller is willing to receive bytes it +/// cannot check. +/// +/// Unspecified means required. The default has to be the strict one: a caller +/// that never thought about verification is precisely the caller that will not +/// notice unchecked bytes arriving, and a field whose omission silently weakens +/// a guarantee is a guarantee only for people who read the schema. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum VerificationRequirement { + VERIFICATION_REQUIREMENT_UNSPECIFIED = 0i32, + /// Refuse the read rather than serve a range the caller cannot check. A + /// requirement that degrades into a warning when it cannot be met is not a + /// requirement, so this fails with + /// ARTIFACT_ERROR_CODE_VERIFICATION_UNAVAILABLE instead of returning bytes + /// labelled unverifiable. + VERIFICATION_REQUIREMENT_REQUIRED = 1i32, + /// Serve the range even when it cannot be checked. Appropriate for a preview + /// pane and not for anything that will be executed, replayed, or stored + /// elsewhere as the artifact. + VERIFICATION_REQUIREMENT_NOT_REQUIRED = 2i32, +} +impl VerificationRequirement { + ///Idiomatic alias for [`Self::VERIFICATION_REQUIREMENT_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::VERIFICATION_REQUIREMENT_UNSPECIFIED; + ///Idiomatic alias for [`Self::VERIFICATION_REQUIREMENT_REQUIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Required: Self = Self::VERIFICATION_REQUIREMENT_REQUIRED; + ///Idiomatic alias for [`Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotRequired: Self = Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED; +} +impl ::core::default::Default for VerificationRequirement { + fn default() -> Self { + Self::VERIFICATION_REQUIREMENT_UNSPECIFIED + } +} +impl ::serde::Serialize for VerificationRequirement { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for VerificationRequirement { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = VerificationRequirement; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(VerificationRequirement) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for VerificationRequirement { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for VerificationRequirement { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_UNSPECIFIED) + } + 1i32 => ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_REQUIRED), + 2i32 => { + ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::VERIFICATION_REQUIREMENT_UNSPECIFIED => { + "VERIFICATION_REQUIREMENT_UNSPECIFIED" + } + Self::VERIFICATION_REQUIREMENT_REQUIRED => { + "VERIFICATION_REQUIREMENT_REQUIRED" + } + Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED => { + "VERIFICATION_REQUIREMENT_NOT_REQUIRED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "VERIFICATION_REQUIREMENT_UNSPECIFIED" => { + ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_UNSPECIFIED) + } + "VERIFICATION_REQUIREMENT_REQUIRED" => { + ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_REQUIRED) + } + "VERIFICATION_REQUIREMENT_NOT_REQUIRED" => { + ::core::option::Option::Some(Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::VERIFICATION_REQUIREMENT_UNSPECIFIED, + Self::VERIFICATION_REQUIREMENT_REQUIRED, + Self::VERIFICATION_REQUIREMENT_NOT_REQUIRED, + ] + } +} +/// RangeVerifiability is whether the caller can check what it just received. +/// +/// It reports what the caller can do, not what the server did, and the +/// distinction is the point. A server field reading "verified" would be the +/// party under suspicion certifying itself: the only check worth anything here +/// is one the caller performs, against a manifest digest that came from the +/// event log rather than from the artifact store. So this contract's obligation +/// is to serve ranges in a shape that can be checked, and to say plainly when it +/// has not. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RangeVerifiability { + RANGE_VERIFIABILITY_UNSPECIFIED = 0i32, + /// The served range covers whole chunks, so every byte in it is covered by a + /// chunk digest the caller can obtain and check. + RANGE_VERIFIABILITY_VERIFIABLE = 1i32, + /// The artifact was stored without chunk hashing. Nothing about this range can + /// be checked short of reading the entire artifact and hashing it. + RANGE_VERIFIABILITY_NO_MANIFEST = 2i32, + /// A manifest exists and the served range does not align to it, because the + /// caller allowed an unverifiable read. The partial chunks at its edges are + /// not covered by any digest the caller can check. + RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED = 3i32, +} +impl RangeVerifiability { + ///Idiomatic alias for [`Self::RANGE_VERIFIABILITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RANGE_VERIFIABILITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::RANGE_VERIFIABILITY_VERIFIABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Verifiable: Self = Self::RANGE_VERIFIABILITY_VERIFIABLE; + ///Idiomatic alias for [`Self::RANGE_VERIFIABILITY_NO_MANIFEST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NoManifest: Self = Self::RANGE_VERIFIABILITY_NO_MANIFEST; + ///Idiomatic alias for [`Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RangeNotAligned: Self = Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED; +} +impl ::core::default::Default for RangeVerifiability { + fn default() -> Self { + Self::RANGE_VERIFIABILITY_UNSPECIFIED + } +} +impl ::serde::Serialize for RangeVerifiability { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RangeVerifiability { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RangeVerifiability; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(RangeVerifiability) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RangeVerifiability { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RangeVerifiability { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_VERIFIABLE), + 2i32 => ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_NO_MANIFEST), + 3i32 => { + ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RANGE_VERIFIABILITY_UNSPECIFIED => "RANGE_VERIFIABILITY_UNSPECIFIED", + Self::RANGE_VERIFIABILITY_VERIFIABLE => "RANGE_VERIFIABILITY_VERIFIABLE", + Self::RANGE_VERIFIABILITY_NO_MANIFEST => "RANGE_VERIFIABILITY_NO_MANIFEST", + Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED => { + "RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RANGE_VERIFIABILITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_UNSPECIFIED) + } + "RANGE_VERIFIABILITY_VERIFIABLE" => { + ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_VERIFIABLE) + } + "RANGE_VERIFIABILITY_NO_MANIFEST" => { + ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_NO_MANIFEST) + } + "RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED" => { + ::core::option::Option::Some(Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RANGE_VERIFIABILITY_UNSPECIFIED, + Self::RANGE_VERIFIABILITY_VERIFIABLE, + Self::RANGE_VERIFIABILITY_NO_MANIFEST, + Self::RANGE_VERIFIABILITY_RANGE_NOT_ALIGNED, + ] + } +} +/// ReadArtifactRangeRequest asks for a bounded window of an artifact's bytes. +/// +/// There is no request for the whole artifact and no way to express one. A +/// caller that wants all 40 MB issues successive ranges; the transport carries +/// JSON-RPC bodies over NATS (ADR#0055, ADR#0056) and has no streaming call, so +/// successive bounded reads are the streaming primitive rather than a +/// workaround for the absence of one. The practical difference is that the +/// bound is always the caller's and always visible, instead of a limit +/// discovered when a response fails to fit. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReadArtifactRangeRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// First byte requested, counted from the start of the artifact. + /// + /// Field 3: `offset` + #[serde(rename = "offset", with = "::buffa::json_helpers::uint64")] + pub offset: u64, + /// How many bytes are wanted. The server may serve fewer at the end of the + /// artifact or under its own cap, and may serve more only to reach a chunk + /// boundary when verification was required. What was served is on the + /// response; a caller must read it rather than assume it got what it asked + /// for. + /// + /// Field 4: `length` + #[serde(rename = "length", with = "::buffa::json_helpers::uint64")] + pub length: u64, + /// Field 5: `verification` + #[serde( + rename = "verification", + with = "::buffa::json_helpers::opt_enum", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub verification: ::core::option::Option< + ::buffa::EnumValue, + >, +} +impl ::core::fmt::Debug for ReadArtifactRangeRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReadArtifactRangeRequest") + .field("session_id", &self.session_id) + .field("artifact_id", &self.artifact_id) + .field("offset", &self.offset) + .field("length", &self.length) + .field("verification", &self.verification) + .finish() + } +} +impl ReadArtifactRangeRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest"; +} +impl ReadArtifactRangeRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::verification`] to `Some(value)`, consuming and returning `self`. + pub fn with_verification( + mut self, + value: impl Into<::buffa::EnumValue>, + ) -> Self { + self.verification = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ReadArtifactRangeRequest); +impl ::buffa::MessageName for ReadArtifactRangeRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadArtifactRangeRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest"; +} +impl ::buffa::Message for ReadArtifactRangeRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.length) as u64; + if let Some(ref v) = self.verification { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + ::buffa::types::put_uint64_field(3u32, self.offset, buf); + ::buffa::types::put_uint64_field(4u32, self.length, buf); + if let Some(ref v) = self.verification { + ::buffa::types::put_int32_field(5u32, v.to_i32(), buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.offset = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.length = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.verification = ::core::option::Option::Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.artifact_id.clear(); + self.offset = 0u64; + self.length = 0u64; + self.verification = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReadArtifactRangeRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __READ_ARTIFACT_RANGE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReadArtifactRangeResponse carries the served bytes and says what they are +/// worth. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReadArtifactRangeResponse { + /// Field 1: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// Field 2: `availability` + #[serde(rename = "availability", with = "::buffa::json_helpers::proto_enum")] + pub availability: ::buffa::EnumValue, + /// First byte actually served. Equal to the requested offset unless + /// verification required aligning down to a chunk boundary. + /// + /// Field 3: `offset` + #[serde(rename = "offset", with = "::buffa::json_helpers::uint64")] + pub offset: u64, + /// The served bytes. Empty for every availability except + /// ARTIFACT_AVAILABILITY_AVAILABLE. Its length is the served length; a + /// separate length field would be a second copy of a fact the bytes already + /// carry, and the copy is what a caller would trust when they disagree. + /// + /// Field 4: `content` + #[serde( + rename = "content", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub content: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Total size of the artifact. This is what makes the response + /// self-describing: with the served offset and length, a caller derives + /// reaching the end of the artifact from being cut short by the server + /// without a flag that could contradict the numbers next to it, and knows + /// where to resume without a second call. + /// + /// Field 5: `size_bytes` + #[serde( + rename = "sizeBytes", + alias = "size_bytes", + with = "::buffa::json_helpers::uint64" + )] + pub size_bytes: u64, + /// Field 6: `verifiability` + #[serde(rename = "verifiability", with = "::buffa::json_helpers::proto_enum")] + pub verifiability: ::buffa::EnumValue, + /// Field 7: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ReadArtifactRangeResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReadArtifactRangeResponse") + .field("artifact_id", &self.artifact_id) + .field("availability", &self.availability) + .field("offset", &self.offset) + .field("content", &self.content) + .field("size_bytes", &self.size_bytes) + .field("verifiability", &self.verifiability) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl ReadArtifactRangeResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse"; +} +impl ReadArtifactRangeResponse { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::content`] to `Some(value)`, consuming and returning `self`. + pub fn with_content( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.content = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ReadArtifactRangeResponse); +impl ::buffa::MessageName for ReadArtifactRangeResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadArtifactRangeResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse"; +} +impl ::buffa::Message for ReadArtifactRangeResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.offset) as u64; + if let Some(ref v) = self.content { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + { + let val = self.verifiability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + ::buffa::types::put_uint64_field(3u32, self.offset, buf); + if let Some(ref v) = self.content { + ::buffa::types::put_shared_bytes_field(4u32, v, buf); + } + ::buffa::types::put_uint64_field(5u32, self.size_bytes, buf); + ::buffa::types::put_int32_field(6u32, self.verifiability.to_i32(), buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.offset = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self.content.get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.size_bytes = ::buffa::types::decode_uint64(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.verifiability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.artifact_id.clear(); + self.availability = ::buffa::EnumValue::from(0); + self.offset = 0u64; + self.content = ::core::option::Option::None; + self.size_bytes = 0u64; + self.verifiability = ::buffa::EnumValue::from(0); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReadArtifactRangeResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __READ_ARTIFACT_RANGE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadArtifactRangeResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.__view.rs new file mode 100644 index 0000000000..62ffe6fd52 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.__view.rs @@ -0,0 +1,1208 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/stat_artifact.proto + +/// StatArtifactRequest asks what an artifact is, without asking for it. +/// +/// There is deliberately no field on this request that could cause bytes to be +/// returned: no range, no "include content", no size threshold under which the +/// content comes along. A caller reaching for metadata about a 40 MB artifact +/// must not be able to fetch 40 MB by setting a field wrong, and a reviewer must +/// not have to read a value to know a call was cheap. This is the same +/// structural argument that gives DiagnoseSession no repair mode. +#[derive(Clone, Debug, Default)] +pub struct StatArtifactRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `artifact_id` + pub artifact_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StatArtifactRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StatArtifactRequestView<'a> { + type Owned = super::super::StatArtifactRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::StatArtifactRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::StatArtifactRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StatArtifactRequest { + session_id: self.session_id.to_string(), + artifact_id: self.artifact_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StatArtifactRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StatArtifactRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StatArtifactRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "StatArtifactRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest"; +} +::buffa::impl_default_view_instance!(StatArtifactRequestView); +::buffa::impl_view_reborrow!(StatArtifactRequestView); +/** Self-contained, `'static` owned view of a `StatArtifactRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`StatArtifactRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StatArtifactRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StatArtifactRequestOwnedView( + ::buffa::OwnedView>, +); +impl StatArtifactRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StatArtifactRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StatArtifactRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StatArtifactRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StatArtifactRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StatArtifactRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StatArtifactRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StatArtifactRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StatArtifactRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StatArtifactRequest { + type View<'a> = StatArtifactRequestView<'a>; + type ViewHandle = StatArtifactRequestOwnedView; +} +impl ::serde::Serialize for StatArtifactRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// StatArtifactResponse describes the artifact and what can be done with it. +#[derive(Clone, Debug, Default)] +pub struct StatArtifactResponseView<'a> { + /// Field 1: `artifact_id` + pub artifact_id: &'a str, + /// Field 2: `availability` + pub availability: ::buffa::EnumValue, + /// Short human-readable preview recorded with the artifact; empty when none + /// was produced. Present regardless of availability, because a preview is + /// recorded on the log rather than stored with the bytes and so survives their + /// erasure or loss. For many callers this is the whole answer, and the reason + /// a preview is not a range read is that it costs nothing to serve. + /// + /// Field 3: `preview` + pub preview: ::core::option::Option<&'a str>, + /// True when preview is a truncation of the full content. + /// + /// Field 4: `preview_truncated` + pub preview_truncated: bool, + /// Set only for ARTIFACT_AVAILABILITY_AVAILABLE. Every other availability has + /// no readable bytes to describe, and a size or digest reported next to one of + /// them would describe something the caller cannot obtain. + /// + /// Field 5: `content` + pub content: ::buffa::MessageFieldView< + super::super::__buffa::view::ReadableContentView<'a>, + >, + /// When availability was determined. Availability is an observation of an + /// external store at a moment, not a durable property of the artifact, and a + /// caller acting on it later is acting on a claim that has since expired. + /// + /// Field 6: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StatArtifactResponseView<'a> { + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `availability` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_availability(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `preview_truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_preview_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for StatArtifactResponseView<'a> { + type Owned = super::super::StatArtifactResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.preview = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.preview_truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.content.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.content = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::StatArtifactResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::StatArtifactResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StatArtifactResponse { + artifact_id: self.artifact_id.to_string(), + availability: self.availability, + preview: self.preview.map(|s| s.to_string()), + preview_truncated: self.preview_truncated, + content: match self.content.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReadableContent, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StatArtifactResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.preview { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.content.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.content.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + if let Some(ref v) = self.preview { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_bool_field(4u32, self.preview_truncated, buf); + if self.content.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.content.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StatArtifactResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + { + __map.serialize_entry("availability", &self.availability)?; + } + if let ::core::option::Option::Some(__v) = self.preview { + __map.serialize_entry("preview", __v)?; + } + { + __map.serialize_entry("previewTruncated", &self.preview_truncated)?; + } + { + if let ::core::option::Option::Some(__v) = self.content.as_option() { + __map.serialize_entry("content", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StatArtifactResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "StatArtifactResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse"; +} +::buffa::impl_default_view_instance!(StatArtifactResponseView); +::buffa::impl_view_reborrow!(StatArtifactResponseView); +/** Self-contained, `'static` owned view of a `StatArtifactResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`StatArtifactResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StatArtifactResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StatArtifactResponseOwnedView( + ::buffa::OwnedView>, +); +impl StatArtifactResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StatArtifactResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StatArtifactResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StatArtifactResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StatArtifactResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StatArtifactResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// Field 2: `availability` + #[must_use] + pub fn availability( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().availability + } + /// Short human-readable preview recorded with the artifact; empty when none + /// was produced. Present regardless of availability, because a preview is + /// recorded on the log rather than stored with the bytes and so survives their + /// erasure or loss. For many callers this is the whole answer, and the reason + /// a preview is not a range read is that it costs nothing to serve. + /// + /// Field 3: `preview` + #[must_use] + pub fn preview(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().preview + } + /// True when preview is a truncation of the full content. + /// + /// Field 4: `preview_truncated` + #[must_use] + pub fn preview_truncated(&self) -> bool { + self.0.reborrow().preview_truncated + } + /// Set only for ARTIFACT_AVAILABILITY_AVAILABLE. Every other availability has + /// no readable bytes to describe, and a size or digest reported next to one of + /// them would describe something the caller cannot obtain. + /// + /// Field 5: `content` + #[must_use] + pub fn content( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReadableContentView<'_>, + > { + &self.0.reborrow().content + } + /// When availability was determined. Availability is an observation of an + /// external store at a moment, not a durable property of the artifact, and a + /// caller acting on it later is acting on a claim that has since expired. + /// + /// Field 6: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StatArtifactResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StatArtifactResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StatArtifactResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StatArtifactResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StatArtifactResponse { + type View<'a> = StatArtifactResponseView<'a>; + type ViewHandle = StatArtifactResponseOwnedView; +} +impl ::serde::Serialize for StatArtifactResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReadableContent describes bytes a caller can actually get. +#[derive(Clone, Debug, Default)] +pub struct ReadableContentView<'a> { + /// Field 1: `size_bytes` + pub size_bytes: u64, + /// Decoded media type of the stored bytes. + /// + /// Field 2: `mime` + pub mime: &'a str, + /// Hash algorithm of `digest`, for example "sha256". + /// + /// Field 3: `digest_algorithm` + pub digest_algorithm: &'a str, + /// Content digest over the whole artifact, as recorded on the log. Checking a + /// range against this one requires reading every byte, which is what + /// `chunk_size_bytes` exists to avoid. + /// + /// Field 4: `digest` + pub digest: &'a [u8], + /// Chunk size of this artifact's manifest, when it has one. Unset means the + /// artifact was stored without chunk hashing, so no range of it can be + /// checked, and a caller that needs a checkable read should learn that here + /// rather than by having a range read refused. + /// + /// Field 5: `chunk_size_bytes` + pub chunk_size_bytes: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReadableContentView<'a> { + /**Whether required field `size_bytes` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_size_bytes(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `mime` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_mime(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `digest_algorithm` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_digest_algorithm(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `digest` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_digest(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReadableContentView<'a> { + type Owned = super::super::ReadableContent; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.size_bytes = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.mime = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.digest_algorithm = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.digest = ::buffa::types::borrow_bytes(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.chunk_size_bytes = Some(::buffa::types::decode_uint64(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReadableContent { + size_bytes: self.size_bytes, + mime: self.mime.to_string(), + digest_algorithm: self.digest_algorithm.to_string(), + digest: (self.digest).to_vec(), + chunk_size_bytes: self.chunk_size_bytes, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReadableContentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.mime) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.digest_algorithm) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.digest) as u64; + if let Some(v) = self.chunk_size_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.size_bytes, buf); + ::buffa::types::put_string_field(2u32, &self.mime, buf); + ::buffa::types::put_string_field(3u32, &self.digest_algorithm, buf); + ::buffa::types::put_shared_bytes_field(4u32, &self.digest, buf); + if let Some(v) = self.chunk_size_bytes { + ::buffa::types::put_uint64_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReadableContentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "sizeBytes", + &::buffa::json_helpers::ProtoJson(&self.size_bytes), + )?; + } + { + __map.serialize_entry("mime", self.mime)?; + } + { + __map.serialize_entry("digestAlgorithm", self.digest_algorithm)?; + } + { + __map + .serialize_entry( + "digest", + &::buffa::json_helpers::BytesJson(self.digest), + )?; + } + if let ::core::option::Option::Some(__v) = self.chunk_size_bytes { + __map + .serialize_entry( + "chunkSizeBytes", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReadableContentView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadableContent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadableContent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadableContent"; +} +::buffa::impl_default_view_instance!(ReadableContentView); +::buffa::impl_view_reborrow!(ReadableContentView); +/** Self-contained, `'static` owned view of a `ReadableContent` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReadableContentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReadableContentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReadableContentOwnedView(::buffa::OwnedView>); +impl ReadableContentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadableContentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadableContentOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReadableContent, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadableContentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReadableContentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReadableContentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReadableContent { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `size_bytes` + #[must_use] + pub fn size_bytes(&self) -> u64 { + self.0.reborrow().size_bytes + } + /// Decoded media type of the stored bytes. + /// + /// Field 2: `mime` + #[must_use] + pub fn mime(&self) -> &'_ str { + self.0.reborrow().mime + } + /// Hash algorithm of `digest`, for example "sha256". + /// + /// Field 3: `digest_algorithm` + #[must_use] + pub fn digest_algorithm(&self) -> &'_ str { + self.0.reborrow().digest_algorithm + } + /// Content digest over the whole artifact, as recorded on the log. Checking a + /// range against this one requires reading every byte, which is what + /// `chunk_size_bytes` exists to avoid. + /// + /// Field 4: `digest` + #[must_use] + pub fn digest(&self) -> &'_ [u8] { + self.0.reborrow().digest + } + /// Chunk size of this artifact's manifest, when it has one. Unset means the + /// artifact was stored without chunk hashing, so no range of it can be + /// checked, and a caller that needs a checkable read should learn that here + /// rather than by having a range read refused. + /// + /// Field 5: `chunk_size_bytes` + #[must_use] + pub fn chunk_size_bytes(&self) -> ::core::option::Option { + self.0.reborrow().chunk_size_bytes + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReadableContentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReadableContentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReadableContentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReadableContentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReadableContent { + type View<'a> = ReadableContentView<'a>; + type ViewHandle = ReadableContentOwnedView; +} +impl ::serde::Serialize for ReadableContentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.rs new file mode 100644 index 0000000000..27b1d0c39a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.artifacts.v1alpha1.stat_artifact.rs @@ -0,0 +1,601 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/artifacts/v1alpha1/stat_artifact.proto + +/// StatArtifactRequest asks what an artifact is, without asking for it. +/// +/// There is deliberately no field on this request that could cause bytes to be +/// returned: no range, no "include content", no size threshold under which the +/// content comes along. A caller reaching for metadata about a 40 MB artifact +/// must not be able to fetch 40 MB by setting a field wrong, and a reviewer must +/// not have to read a value to know a call was cheap. This is the same +/// structural argument that gives DiagnoseSession no repair mode. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StatArtifactRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for StatArtifactRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StatArtifactRequest") + .field("session_id", &self.session_id) + .field("artifact_id", &self.artifact_id) + .finish() + } +} +impl StatArtifactRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest"; +} +::buffa::impl_default_instance!(StatArtifactRequest); +impl ::buffa::MessageName for StatArtifactRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "StatArtifactRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest"; +} +impl ::buffa::Message for StatArtifactRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.artifact_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StatArtifactRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STAT_ARTIFACT_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// StatArtifactResponse describes the artifact and what can be done with it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StatArtifactResponse { + /// Field 1: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// Field 2: `availability` + #[serde(rename = "availability", with = "::buffa::json_helpers::proto_enum")] + pub availability: ::buffa::EnumValue, + /// Short human-readable preview recorded with the artifact; empty when none + /// was produced. Present regardless of availability, because a preview is + /// recorded on the log rather than stored with the bytes and so survives their + /// erasure or loss. For many callers this is the whole answer, and the reason + /// a preview is not a range read is that it costs nothing to serve. + /// + /// Field 3: `preview` + #[serde(rename = "preview", skip_serializing_if = "::core::option::Option::is_none")] + pub preview: ::core::option::Option<::buffa::alloc::string::String>, + /// True when preview is a truncation of the full content. + /// + /// Field 4: `preview_truncated` + #[serde( + rename = "previewTruncated", + alias = "preview_truncated", + with = "::buffa::json_helpers::proto_bool" + )] + pub preview_truncated: bool, + /// Set only for ARTIFACT_AVAILABILITY_AVAILABLE. Every other availability has + /// no readable bytes to describe, and a size or digest reported next to one of + /// them would describe something the caller cannot obtain. + /// + /// Field 5: `content` + #[serde( + rename = "content", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub content: ::buffa::MessageField< + ReadableContent, + ::buffa::Inline, + >, + /// When availability was determined. Availability is an observation of an + /// external store at a moment, not a durable property of the artifact, and a + /// caller acting on it later is acting on a claim that has since expired. + /// + /// Field 6: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for StatArtifactResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StatArtifactResponse") + .field("artifact_id", &self.artifact_id) + .field("availability", &self.availability) + .field("preview", &self.preview) + .field("preview_truncated", &self.preview_truncated) + .field("content", &self.content) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl StatArtifactResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse"; +} +impl StatArtifactResponse { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::preview`] to `Some(value)`, consuming and returning `self`. + pub fn with_preview( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.preview = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(StatArtifactResponse); +impl ::buffa::MessageName for StatArtifactResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "StatArtifactResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse"; +} +impl ::buffa::Message for StatArtifactResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.preview { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.content.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.content.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + if let Some(ref v) = self.preview { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_bool_field(4u32, self.preview_truncated, buf); + if self.content.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.content.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.preview.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.preview_truncated = ::buffa::types::decode_bool(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.content.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.artifact_id.clear(); + self.availability = ::buffa::EnumValue::from(0); + self.preview = ::core::option::Option::None; + self.preview_truncated = false; + self.content = ::buffa::MessageField::none(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StatArtifactResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STAT_ARTIFACT_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.StatArtifactResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReadableContent describes bytes a caller can actually get. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReadableContent { + /// Field 1: `size_bytes` + #[serde( + rename = "sizeBytes", + alias = "size_bytes", + with = "::buffa::json_helpers::uint64" + )] + pub size_bytes: u64, + /// Decoded media type of the stored bytes. + /// + /// Field 2: `mime` + #[serde(rename = "mime", with = "::buffa::json_helpers::proto_string")] + pub mime: ::buffa::alloc::string::String, + /// Hash algorithm of `digest`, for example "sha256". + /// + /// Field 3: `digest_algorithm` + #[serde( + rename = "digestAlgorithm", + alias = "digest_algorithm", + with = "::buffa::json_helpers::proto_string" + )] + pub digest_algorithm: ::buffa::alloc::string::String, + /// Content digest over the whole artifact, as recorded on the log. Checking a + /// range against this one requires reading every byte, which is what + /// `chunk_size_bytes` exists to avoid. + /// + /// Field 4: `digest` + #[serde(rename = "digest", with = "::buffa::json_helpers::bytes")] + pub digest: ::buffa::alloc::vec::Vec, + /// Chunk size of this artifact's manifest, when it has one. Unset means the + /// artifact was stored without chunk hashing, so no range of it can be + /// checked, and a caller that needs a checkable read should learn that here + /// rather than by having a range read refused. + /// + /// Field 5: `chunk_size_bytes` + #[serde( + rename = "chunkSizeBytes", + alias = "chunk_size_bytes", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub chunk_size_bytes: ::core::option::Option, +} +impl ::core::fmt::Debug for ReadableContent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReadableContent") + .field("size_bytes", &self.size_bytes) + .field("mime", &self.mime) + .field("digest_algorithm", &self.digest_algorithm) + .field("digest", &self.digest) + .field("chunk_size_bytes", &self.chunk_size_bytes) + .finish() + } +} +impl ReadableContent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadableContent"; +} +impl ReadableContent { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::chunk_size_bytes`] to `Some(value)`, consuming and returning `self`. + pub fn with_chunk_size_bytes(mut self, value: u64) -> Self { + self.chunk_size_bytes = Some(value); + self + } +} +::buffa::impl_default_instance!(ReadableContent); +impl ::buffa::MessageName for ReadableContent { + const PACKAGE: &'static str = "trogonai.session.sessions.artifacts.v1alpha1"; + const NAME: &'static str = "ReadableContent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.artifacts.v1alpha1.ReadableContent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadableContent"; +} +impl ::buffa::Message for ReadableContent { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.mime) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.digest_algorithm) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.digest) as u64; + if let Some(v) = self.chunk_size_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.size_bytes, buf); + ::buffa::types::put_string_field(2u32, &self.mime, buf); + ::buffa::types::put_string_field(3u32, &self.digest_algorithm, buf); + ::buffa::types::put_shared_bytes_field(4u32, &self.digest, buf); + if let Some(v) = self.chunk_size_bytes { + ::buffa::types::put_uint64_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.size_bytes = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.mime, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.digest_algorithm, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes(&mut self.digest, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.chunk_size_bytes = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.size_bytes = 0u64; + self.mime.clear(); + self.digest_algorithm.clear(); + self.digest.clear(); + self.chunk_size_bytes = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReadableContent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __READABLE_CONTENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.artifacts.v1alpha1.ReadableContent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.mod.rs new file mode 100644 index 0000000000..82ad94ba73 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.mod.rs @@ -0,0 +1,43 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.diff.v1alpha1.structured_diff.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.diff.v1alpha1.structured_diff.__view.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__STRUCTURED_DIFF_JSON_ANY); + reg.register_json_any(super::__DIFF_HUNK_JSON_ANY); + reg.register_json_any(super::__DIFF_LINE_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::StructuredDiffView; +#[doc(inline)] +pub use self::__buffa::view::StructuredDiffOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DiffHunkView; +#[doc(inline)] +pub use self::__buffa::view::DiffHunkOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DiffLineView; +#[doc(inline)] +pub use self::__buffa::view::DiffLineOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.__view.rs new file mode 100644 index 0000000000..f7ae72e452 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.__view.rs @@ -0,0 +1,1132 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/diff/v1alpha1/structured_diff.proto + +/// Structured diff artifact content for a recorded file change. +/// +/// This is artifact payload, not an event. It sits behind +/// `DiffSummary.rendered`, which is a claim-check like any other, and a reader +/// finds it there by the media type on `ArtifactRef.mime`. The alternative was +/// putting hunks on FileChanged, which would put a presentation shape into a log +/// that is never truncated (ADR#0035 facet 7): every review UI decision about how +/// much context to show would become permanent history. +/// +/// It is defined in its own subtree and does not import the write-side types +/// (ADR#0035 facet 3). A diff format changes for rendering reasons, on a review +/// tool's schedule, and nothing about the session domain should have to move when +/// it does. +/// +/// The counts on DiffSummary stay authoritative and are never recomputed from +/// this. `DiffSummary.truncated` exists precisely because the artifact may omit +/// hunks while the inline counts remain exact, so a reader that recounts from the +/// hunks here will get a smaller number and will be wrong. +/// +/// StructuredDiff is a parsed diff for one file change. +#[derive(Clone, Debug, Default)] +pub struct StructuredDiffView<'a> { + /// Version of this structure's semantics, incremented when the meaning of an + /// existing field changes rather than when fields are added. + /// + /// It is here and not only in the media type because an artifact outlives the + /// reference that found it. A stored diff read years later through a generic + /// artifact path has to be able to say what it is without the mime string that + /// was attached to the claim-check. + /// + /// Field 1: `format_version` + pub format_version: u32, + /// Field 2: `hunks` + pub hunks: ::buffa::RepeatedView<'a, super::super::__buffa::view::DiffHunkView<'a>>, + /// True when hunks were omitted. Mirrors DiffSummary.truncated so the artifact + /// is self-describing: a consumer holding only these bytes must be able to tell + /// a complete diff from a partial one without the summary that pointed at it. + /// + /// Field 3: `truncated` + pub truncated: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StructuredDiffView<'a> { + /**Whether required field `format_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_format_version(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StructuredDiffView<'a> { + type Owned = super::super::StructuredDiff; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.format_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.hunks + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StructuredDiff { + format_version: self.format_version, + hunks: self + .hunks + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + truncated: self.truncated, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StructuredDiffView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + for v in &self.hunks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.format_version, buf); + for v in &self.hunks { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StructuredDiffView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "formatVersion", + &::buffa::json_helpers::ProtoJson(&self.format_version), + )?; + } + if !self.hunks.is_empty() { + __map.serialize_entry("hunks", &*self.hunks)?; + } + { + __map.serialize_entry("truncated", &self.truncated)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StructuredDiffView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "StructuredDiff"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.StructuredDiff"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.StructuredDiff"; +} +::buffa::impl_default_view_instance!(StructuredDiffView); +::buffa::impl_view_reborrow!(StructuredDiffView); +/** Self-contained, `'static` owned view of a `StructuredDiff` message. + + Wraps [`::buffa::OwnedView`]`<`[`StructuredDiffView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StructuredDiffView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StructuredDiffOwnedView(::buffa::OwnedView>); +impl StructuredDiffOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StructuredDiffOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StructuredDiffOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StructuredDiff, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StructuredDiffOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StructuredDiffView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StructuredDiffView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StructuredDiff { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Version of this structure's semantics, incremented when the meaning of an + /// existing field changes rather than when fields are added. + /// + /// It is here and not only in the media type because an artifact outlives the + /// reference that found it. A stored diff read years later through a generic + /// artifact path has to be able to say what it is without the mime string that + /// was attached to the claim-check. + /// + /// Field 1: `format_version` + #[must_use] + pub fn format_version(&self) -> u32 { + self.0.reborrow().format_version + } + /// Field 2: `hunks` + #[must_use] + pub fn hunks( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::DiffHunkView<'_>> { + &self.0.reborrow().hunks + } + /// True when hunks were omitted. Mirrors DiffSummary.truncated so the artifact + /// is self-describing: a consumer holding only these bytes must be able to tell + /// a complete diff from a partial one without the summary that pointed at it. + /// + /// Field 3: `truncated` + #[must_use] + pub fn truncated(&self) -> bool { + self.0.reborrow().truncated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StructuredDiffOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StructuredDiffOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StructuredDiffOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StructuredDiffOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StructuredDiff { + type View<'a> = StructuredDiffView<'a>; + type ViewHandle = StructuredDiffOwnedView; +} +impl ::serde::Serialize for StructuredDiffOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// DiffHunk is one contiguous region of change with its surrounding context. +#[derive(Clone, Debug, Default)] +pub struct DiffHunkView<'a> { + /// First line of this hunk in the before-content, 1-based. Zero when the + /// before-content does not exist, which is the create case. + /// + /// Field 1: `old_start` + pub old_start: u32, + /// First line of this hunk in the after-content, 1-based. Zero when the + /// after-content does not exist, which is the delete case. + /// + /// Field 2: `new_start` + pub new_start: u32, + /// Section heading a renderer can show above the hunk, such as the enclosing + /// function. Empty when none was determined. + /// + /// Field 3: `heading` + pub heading: ::core::option::Option<&'a str>, + /// Field 4: `lines` + pub lines: ::buffa::RepeatedView<'a, super::super::__buffa::view::DiffLineView<'a>>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DiffHunkView<'a> { + /**Whether required field `old_start` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_old_start(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `new_start` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_new_start(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DiffHunkView<'a> { + type Owned = super::super::DiffHunk; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.old_start = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.new_start = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.heading = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.lines + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DiffHunk { + old_start: self.old_start, + new_start: self.new_start, + heading: self.heading.map(|s| s.to_string()), + lines: self + .lines + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DiffHunkView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.old_start) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.new_start) as u64; + if let Some(ref v) = self.heading { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.lines { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.old_start, buf); + ::buffa::types::put_uint32_field(2u32, self.new_start, buf); + if let Some(ref v) = self.heading { + ::buffa::types::put_string_field(3u32, v, buf); + } + for v in &self.lines { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DiffHunkView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "oldStart", + &::buffa::json_helpers::ProtoJson(&self.old_start), + )?; + } + { + __map + .serialize_entry( + "newStart", + &::buffa::json_helpers::ProtoJson(&self.new_start), + )?; + } + if let ::core::option::Option::Some(__v) = self.heading { + __map.serialize_entry("heading", __v)?; + } + if !self.lines.is_empty() { + __map.serialize_entry("lines", &*self.lines)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DiffHunkView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "DiffHunk"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.DiffHunk"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffHunk"; +} +::buffa::impl_default_view_instance!(DiffHunkView); +::buffa::impl_view_reborrow!(DiffHunkView); +/** Self-contained, `'static` owned view of a `DiffHunk` message. + + Wraps [`::buffa::OwnedView`]`<`[`DiffHunkView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DiffHunkView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DiffHunkOwnedView(::buffa::OwnedView>); +impl DiffHunkOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(DiffHunkOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiffHunkOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DiffHunk, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiffHunkOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DiffHunkView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DiffHunkView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DiffHunk { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// First line of this hunk in the before-content, 1-based. Zero when the + /// before-content does not exist, which is the create case. + /// + /// Field 1: `old_start` + #[must_use] + pub fn old_start(&self) -> u32 { + self.0.reborrow().old_start + } + /// First line of this hunk in the after-content, 1-based. Zero when the + /// after-content does not exist, which is the delete case. + /// + /// Field 2: `new_start` + #[must_use] + pub fn new_start(&self) -> u32 { + self.0.reborrow().new_start + } + /// Section heading a renderer can show above the hunk, such as the enclosing + /// function. Empty when none was determined. + /// + /// Field 3: `heading` + #[must_use] + pub fn heading(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().heading + } + /// Field 4: `lines` + #[must_use] + pub fn lines( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::DiffLineView<'_>> { + &self.0.reborrow().lines + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DiffHunkOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DiffHunkOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DiffHunkOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DiffHunkOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DiffHunk { + type View<'a> = DiffHunkView<'a>; + type ViewHandle = DiffHunkOwnedView; +} +impl ::serde::Serialize for DiffHunkOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// DiffLine is one line of a hunk. +#[derive(Clone, Debug, Default)] +pub struct DiffLineView<'a> { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// Line content without its trailing newline and without a leading diff marker. + /// The marker is `kind`, so a renderer never has to strip one character off the + /// front of the text and hope it was punctuation rather than content. + /// + /// Empty for LINE_KIND_ELIDED, which stands for lines that are not here. + /// + /// Field 2: `text` + pub text: ::core::option::Option<&'a str>, + /// Line number in the before-content, 1-based. Unset for an added line, which + /// has no position there. Absent rather than zero, so "this line did not exist + /// before" cannot be read as "line zero". + /// + /// Field 3: `old_line` + pub old_line: ::core::option::Option, + /// Line number in the after-content, 1-based. Unset for a removed line. + /// + /// Field 4: `new_line` + pub new_line: ::core::option::Option, + /// How many lines LINE_KIND_ELIDED stands in for. Zero for every other kind. + /// + /// Field 5: `elided_count` + pub elided_count: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DiffLineView<'a> { + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DiffLineView<'a> { + type Owned = super::super::DiffLine; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = Some(::buffa::types::borrow_str(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.old_line = Some(::buffa::types::decode_uint32(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.new_line = Some(::buffa::types::decode_uint32(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.elided_count = Some(::buffa::types::decode_uint32(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DiffLine { + kind: self.kind, + text: self.text.map(|s| s.to_string()), + old_line: self.old_line, + new_line: self.new_line, + elided_count: self.elided_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DiffLineView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.text { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.old_line { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + if let Some(v) = self.new_line { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + if let Some(v) = self.elided_count { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.text { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let Some(v) = self.old_line { + ::buffa::types::put_uint32_field(3u32, v, buf); + } + if let Some(v) = self.new_line { + ::buffa::types::put_uint32_field(4u32, v, buf); + } + if let Some(v) = self.elided_count { + ::buffa::types::put_uint32_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DiffLineView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(__v) = self.text { + __map.serialize_entry("text", __v)?; + } + if let ::core::option::Option::Some(__v) = self.old_line { + __map.serialize_entry("oldLine", &::buffa::json_helpers::ProtoJson(&__v))?; + } + if let ::core::option::Option::Some(__v) = self.new_line { + __map.serialize_entry("newLine", &::buffa::json_helpers::ProtoJson(&__v))?; + } + if let ::core::option::Option::Some(__v) = self.elided_count { + __map + .serialize_entry( + "elidedCount", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DiffLineView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "DiffLine"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.DiffLine"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffLine"; +} +::buffa::impl_default_view_instance!(DiffLineView); +::buffa::impl_view_reborrow!(DiffLineView); +/** Self-contained, `'static` owned view of a `DiffLine` message. + + Wraps [`::buffa::OwnedView`]`<`[`DiffLineView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DiffLineView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DiffLineOwnedView(::buffa::OwnedView>); +impl DiffLineOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(DiffLineOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiffLineOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DiffLine, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiffLineOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DiffLineView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DiffLineView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DiffLine { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Line content without its trailing newline and without a leading diff marker. + /// The marker is `kind`, so a renderer never has to strip one character off the + /// front of the text and hope it was punctuation rather than content. + /// + /// Empty for LINE_KIND_ELIDED, which stands for lines that are not here. + /// + /// Field 2: `text` + #[must_use] + pub fn text(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().text + } + /// Line number in the before-content, 1-based. Unset for an added line, which + /// has no position there. Absent rather than zero, so "this line did not exist + /// before" cannot be read as "line zero". + /// + /// Field 3: `old_line` + #[must_use] + pub fn old_line(&self) -> ::core::option::Option { + self.0.reborrow().old_line + } + /// Line number in the after-content, 1-based. Unset for a removed line. + /// + /// Field 4: `new_line` + #[must_use] + pub fn new_line(&self) -> ::core::option::Option { + self.0.reborrow().new_line + } + /// How many lines LINE_KIND_ELIDED stands in for. Zero for every other kind. + /// + /// Field 5: `elided_count` + #[must_use] + pub fn elided_count(&self) -> ::core::option::Option { + self.0.reborrow().elided_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DiffLineOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DiffLineOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DiffLineOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DiffLineOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DiffLine { + type View<'a> = DiffLineView<'a>; + type ViewHandle = DiffLineOwnedView; +} +impl ::serde::Serialize for DiffLineOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.rs new file mode 100644 index 0000000000..0de9648ed9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.diff.v1alpha1.structured_diff.rs @@ -0,0 +1,812 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/diff/v1alpha1/structured_diff.proto + +/// LineKind is what a line represents in the change. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum LineKind { + LINE_KIND_UNSPECIFIED = 0i32, + /// Unchanged, present for context. + LINE_KIND_CONTEXT = 1i32, + LINE_KIND_ADDED = 2i32, + LINE_KIND_REMOVED = 3i32, + /// A run of lines omitted from this artifact. It carries a count instead of + /// text, so a renderer can show that content is missing rather than joining two + /// distant regions into what looks like adjacent code. + LINE_KIND_ELIDED = 4i32, +} +impl LineKind { + ///Idiomatic alias for [`Self::LINE_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::LINE_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::LINE_KIND_CONTEXT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Context: Self = Self::LINE_KIND_CONTEXT; + ///Idiomatic alias for [`Self::LINE_KIND_ADDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Added: Self = Self::LINE_KIND_ADDED; + ///Idiomatic alias for [`Self::LINE_KIND_REMOVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Removed: Self = Self::LINE_KIND_REMOVED; + ///Idiomatic alias for [`Self::LINE_KIND_ELIDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Elided: Self = Self::LINE_KIND_ELIDED; +} +impl ::core::default::Default for LineKind { + fn default() -> Self { + Self::LINE_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for LineKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for LineKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = LineKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(LineKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for LineKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for LineKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::LINE_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::LINE_KIND_CONTEXT), + 2i32 => ::core::option::Option::Some(Self::LINE_KIND_ADDED), + 3i32 => ::core::option::Option::Some(Self::LINE_KIND_REMOVED), + 4i32 => ::core::option::Option::Some(Self::LINE_KIND_ELIDED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::LINE_KIND_UNSPECIFIED => "LINE_KIND_UNSPECIFIED", + Self::LINE_KIND_CONTEXT => "LINE_KIND_CONTEXT", + Self::LINE_KIND_ADDED => "LINE_KIND_ADDED", + Self::LINE_KIND_REMOVED => "LINE_KIND_REMOVED", + Self::LINE_KIND_ELIDED => "LINE_KIND_ELIDED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "LINE_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::LINE_KIND_UNSPECIFIED) + } + "LINE_KIND_CONTEXT" => ::core::option::Option::Some(Self::LINE_KIND_CONTEXT), + "LINE_KIND_ADDED" => ::core::option::Option::Some(Self::LINE_KIND_ADDED), + "LINE_KIND_REMOVED" => ::core::option::Option::Some(Self::LINE_KIND_REMOVED), + "LINE_KIND_ELIDED" => ::core::option::Option::Some(Self::LINE_KIND_ELIDED), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::LINE_KIND_UNSPECIFIED, + Self::LINE_KIND_CONTEXT, + Self::LINE_KIND_ADDED, + Self::LINE_KIND_REMOVED, + Self::LINE_KIND_ELIDED, + ] + } +} +/// Structured diff artifact content for a recorded file change. +/// +/// This is artifact payload, not an event. It sits behind +/// `DiffSummary.rendered`, which is a claim-check like any other, and a reader +/// finds it there by the media type on `ArtifactRef.mime`. The alternative was +/// putting hunks on FileChanged, which would put a presentation shape into a log +/// that is never truncated (ADR#0035 facet 7): every review UI decision about how +/// much context to show would become permanent history. +/// +/// It is defined in its own subtree and does not import the write-side types +/// (ADR#0035 facet 3). A diff format changes for rendering reasons, on a review +/// tool's schedule, and nothing about the session domain should have to move when +/// it does. +/// +/// The counts on DiffSummary stay authoritative and are never recomputed from +/// this. `DiffSummary.truncated` exists precisely because the artifact may omit +/// hunks while the inline counts remain exact, so a reader that recounts from the +/// hunks here will get a smaller number and will be wrong. +/// +/// StructuredDiff is a parsed diff for one file change. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StructuredDiff { + /// Version of this structure's semantics, incremented when the meaning of an + /// existing field changes rather than when fields are added. + /// + /// It is here and not only in the media type because an artifact outlives the + /// reference that found it. A stored diff read years later through a generic + /// artifact path has to be able to say what it is without the mime string that + /// was attached to the claim-check. + /// + /// Field 1: `format_version` + #[serde( + rename = "formatVersion", + alias = "format_version", + with = "::buffa::json_helpers::uint32" + )] + pub format_version: u32, + /// Field 2: `hunks` + #[serde( + rename = "hunks", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub hunks: ::buffa::alloc::vec::Vec, + /// True when hunks were omitted. Mirrors DiffSummary.truncated so the artifact + /// is self-describing: a consumer holding only these bytes must be able to tell + /// a complete diff from a partial one without the summary that pointed at it. + /// + /// Field 3: `truncated` + #[serde(rename = "truncated", with = "::buffa::json_helpers::proto_bool")] + pub truncated: bool, +} +impl ::core::fmt::Debug for StructuredDiff { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StructuredDiff") + .field("format_version", &self.format_version) + .field("hunks", &self.hunks) + .field("truncated", &self.truncated) + .finish() + } +} +impl StructuredDiff { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.StructuredDiff"; +} +::buffa::impl_default_instance!(StructuredDiff); +impl ::buffa::MessageName for StructuredDiff { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "StructuredDiff"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.StructuredDiff"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.StructuredDiff"; +} +impl ::buffa::Message for StructuredDiff { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + for v in &self.hunks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.format_version, buf); + for v in &self.hunks { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.format_version = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.hunks.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.truncated = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.format_version = 0u32; + self.hunks.clear(); + self.truncated = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for StructuredDiff { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STRUCTURED_DIFF_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.StructuredDiff", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// DiffHunk is one contiguous region of change with its surrounding context. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DiffHunk { + /// First line of this hunk in the before-content, 1-based. Zero when the + /// before-content does not exist, which is the create case. + /// + /// Field 1: `old_start` + #[serde( + rename = "oldStart", + alias = "old_start", + with = "::buffa::json_helpers::uint32" + )] + pub old_start: u32, + /// First line of this hunk in the after-content, 1-based. Zero when the + /// after-content does not exist, which is the delete case. + /// + /// Field 2: `new_start` + #[serde( + rename = "newStart", + alias = "new_start", + with = "::buffa::json_helpers::uint32" + )] + pub new_start: u32, + /// Section heading a renderer can show above the hunk, such as the enclosing + /// function. Empty when none was determined. + /// + /// Field 3: `heading` + #[serde(rename = "heading", skip_serializing_if = "::core::option::Option::is_none")] + pub heading: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `lines` + #[serde( + rename = "lines", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub lines: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for DiffHunk { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DiffHunk") + .field("old_start", &self.old_start) + .field("new_start", &self.new_start) + .field("heading", &self.heading) + .field("lines", &self.lines) + .finish() + } +} +impl DiffHunk { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffHunk"; +} +impl DiffHunk { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::heading`] to `Some(value)`, consuming and returning `self`. + pub fn with_heading( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.heading = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DiffHunk); +impl ::buffa::MessageName for DiffHunk { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "DiffHunk"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.DiffHunk"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffHunk"; +} +impl ::buffa::Message for DiffHunk { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.old_start) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.new_start) as u64; + if let Some(ref v) = self.heading { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.lines { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.old_start, buf); + ::buffa::types::put_uint32_field(2u32, self.new_start, buf); + if let Some(ref v) = self.heading { + ::buffa::types::put_string_field(3u32, v, buf); + } + for v in &self.lines { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.old_start = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.new_start = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.heading.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.lines.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.old_start = 0u32; + self.new_start = 0u32; + self.heading = ::core::option::Option::None; + self.lines.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DiffHunk { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DIFF_HUNK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffHunk", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// DiffLine is one line of a hunk. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DiffLine { + /// Field 1: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Line content without its trailing newline and without a leading diff marker. + /// The marker is `kind`, so a renderer never has to strip one character off the + /// front of the text and hope it was punctuation rather than content. + /// + /// Empty for LINE_KIND_ELIDED, which stands for lines that are not here. + /// + /// Field 2: `text` + #[serde(rename = "text", skip_serializing_if = "::core::option::Option::is_none")] + pub text: ::core::option::Option<::buffa::alloc::string::String>, + /// Line number in the before-content, 1-based. Unset for an added line, which + /// has no position there. Absent rather than zero, so "this line did not exist + /// before" cannot be read as "line zero". + /// + /// Field 3: `old_line` + #[serde( + rename = "oldLine", + alias = "old_line", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub old_line: ::core::option::Option, + /// Line number in the after-content, 1-based. Unset for a removed line. + /// + /// Field 4: `new_line` + #[serde( + rename = "newLine", + alias = "new_line", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub new_line: ::core::option::Option, + /// How many lines LINE_KIND_ELIDED stands in for. Zero for every other kind. + /// + /// Field 5: `elided_count` + #[serde( + rename = "elidedCount", + alias = "elided_count", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub elided_count: ::core::option::Option, +} +impl ::core::fmt::Debug for DiffLine { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DiffLine") + .field("kind", &self.kind) + .field("text", &self.text) + .field("old_line", &self.old_line) + .field("new_line", &self.new_line) + .field("elided_count", &self.elided_count) + .finish() + } +} +impl DiffLine { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffLine"; +} +impl DiffLine { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::text`] to `Some(value)`, consuming and returning `self`. + pub fn with_text( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.text = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::old_line`] to `Some(value)`, consuming and returning `self`. + pub fn with_old_line(mut self, value: u32) -> Self { + self.old_line = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::new_line`] to `Some(value)`, consuming and returning `self`. + pub fn with_new_line(mut self, value: u32) -> Self { + self.new_line = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::elided_count`] to `Some(value)`, consuming and returning `self`. + pub fn with_elided_count(mut self, value: u32) -> Self { + self.elided_count = Some(value); + self + } +} +::buffa::impl_default_instance!(DiffLine); +impl ::buffa::MessageName for DiffLine { + const PACKAGE: &'static str = "trogonai.session.sessions.diff.v1alpha1"; + const NAME: &'static str = "DiffLine"; + const FULL_NAME: &'static str = "trogonai.session.sessions.diff.v1alpha1.DiffLine"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffLine"; +} +impl ::buffa::Message for DiffLine { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.text { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.old_line { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + if let Some(v) = self.new_line { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + if let Some(v) = self.elided_count { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.text { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let Some(v) = self.old_line { + ::buffa::types::put_uint32_field(3u32, v, buf); + } + if let Some(v) = self.new_line { + ::buffa::types::put_uint32_field(4u32, v, buf); + } + if let Some(v) = self.elided_count { + ::buffa::types::put_uint32_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.text.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.old_line = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.new_line = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.elided_count = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.text = ::core::option::Option::None; + self.old_line = ::core::option::Option::None; + self.new_line = ::core::option::Option::None; + self.elided_count = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DiffLine { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DIFF_LINE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.diff.v1alpha1.DiffLine", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.__view.rs new file mode 100644 index 0000000000..136035f503 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.__view.rs @@ -0,0 +1,1579 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/diagnose_session.proto + +/// DiagnoseSessionRequest inspects one session and reports what disagrees. +/// +/// This operation mutates nothing. It is not a mode of a repair operation and it +/// has no flag that would make it one, because a report-only default that lives +/// in a field is one typo away from not being the default. +#[derive(Clone, Debug, Default)] +pub struct DiagnoseSessionRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Checks to run. Empty runs the default set, which excludes the checks whose + /// cost scales with artifact storage rather than with the stream. + /// + /// Field 2: `checks` + pub checks: ::buffa::RepeatedView<'a, ::buffa::EnumValue>, + /// Field 3: `budget` + pub budget: ::buffa::MessageFieldView< + super::super::__buffa::view::InspectionBudgetView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DiagnoseSessionRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DiagnoseSessionRequestView<'a> { + type Owned = super::super::DiagnoseSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.budget.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.budget = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let payload = ::buffa::types::borrow_bytes(&mut cur)?; + view.checks.reserve(::buffa::encoding::count_varints(payload)); + let mut pcur: &[u8] = payload; + while !pcur.is_empty() { + view.checks + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut pcur)?, + ), + ); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + view.checks + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ), + ); + } else { + return Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::DiagnoseSessionRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::DiagnoseSessionRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DiagnoseSessionRequest { + session_id: self.session_id.to_string(), + checks: self.checks.to_vec(), + budget: match self.budget.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::InspectionBudget, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DiagnoseSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if !self.checks.is_empty() { + let payload: u64 = self + .checks + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.budget.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.budget.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if !self.checks.is_empty() { + let payload: u64 = self + .checks + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(2u32, payload, buf); + for v in &self.checks { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.budget.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.budget.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DiagnoseSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + if !self.checks.is_empty() { + __map + .serialize_entry( + "checks", + &::buffa::json_helpers::EnumSeqJson(&self.checks), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.budget.as_option() { + __map.serialize_entry("budget", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DiagnoseSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DiagnoseSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest"; +} +::buffa::impl_default_view_instance!(DiagnoseSessionRequestView); +::buffa::impl_view_reborrow!(DiagnoseSessionRequestView); +/** Self-contained, `'static` owned view of a `DiagnoseSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`DiagnoseSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DiagnoseSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DiagnoseSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl DiagnoseSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DiagnoseSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DiagnoseSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DiagnoseSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DiagnoseSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Checks to run. Empty runs the default set, which excludes the checks whose + /// cost scales with artifact storage rather than with the stream. + /// + /// Field 2: `checks` + #[must_use] + pub fn checks( + &self, + ) -> &::buffa::RepeatedView<'_, ::buffa::EnumValue> { + &self.0.reborrow().checks + } + /// Field 3: `budget` + #[must_use] + pub fn budget( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::InspectionBudgetView<'_>, + > { + &self.0.reborrow().budget + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DiagnoseSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DiagnoseSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DiagnoseSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DiagnoseSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DiagnoseSessionRequest { + type View<'a> = DiagnoseSessionRequestView<'a>; + type ViewHandle = DiagnoseSessionRequestOwnedView; +} +impl ::serde::Serialize for DiagnoseSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// InspectionBudget bounds the work a diagnosis may do. +/// +/// Inspection is unbounded by nature: verifying every artifact digest on a long +/// session means reading every artifact. Without a budget the doctor becomes a +/// load generator that operators learn not to run, and a diagnostic nobody dares +/// use is worth nothing. +/// +/// Unset fields mean the server's default, not unlimited. +#[derive(Clone, Debug, Default)] +pub struct InspectionBudgetView<'a> { + /// Field 1: `max_events_scanned` + pub max_events_scanned: ::core::option::Option, + /// Field 2: `max_artifacts_verified` + pub max_artifacts_verified: ::core::option::Option, + /// Field 3: `max_duration` + pub max_duration: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, +} +impl<'a> ::buffa::MessageView<'a> for InspectionBudgetView<'a> { + type Owned = super::super::InspectionBudget; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_events_scanned = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_artifacts_verified = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.max_duration.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.max_duration = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::InspectionBudget { + max_events_scanned: self.max_events_scanned, + max_artifacts_verified: self.max_artifacts_verified, + max_duration: match self.max_duration.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for InspectionBudgetView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_events_scanned { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_artifacts_verified { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_events_scanned { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_artifacts_verified { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for InspectionBudgetView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(__v) = self.max_events_scanned { + __map + .serialize_entry( + "maxEventsScanned", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.max_artifacts_verified { + __map + .serialize_entry( + "maxArtifactsVerified", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.max_duration.as_option() { + __map.serialize_entry("maxDuration", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for InspectionBudgetView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "InspectionBudget"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.InspectionBudget"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.InspectionBudget"; +} +::buffa::impl_default_view_instance!(InspectionBudgetView); +::buffa::impl_view_reborrow!(InspectionBudgetView); +/** Self-contained, `'static` owned view of a `InspectionBudget` message. + + Wraps [`::buffa::OwnedView`]`<`[`InspectionBudgetView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`InspectionBudgetView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct InspectionBudgetOwnedView(::buffa::OwnedView>); +impl InspectionBudgetOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InspectionBudgetOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InspectionBudgetOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::InspectionBudget, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InspectionBudgetOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`InspectionBudgetView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &InspectionBudgetView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::InspectionBudget { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `max_events_scanned` + #[must_use] + pub fn max_events_scanned(&self) -> ::core::option::Option { + self.0.reborrow().max_events_scanned + } + /// Field 2: `max_artifacts_verified` + #[must_use] + pub fn max_artifacts_verified(&self) -> ::core::option::Option { + self.0.reborrow().max_artifacts_verified + } + /// Field 3: `max_duration` + #[must_use] + pub fn max_duration( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().max_duration + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for InspectionBudgetOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + InspectionBudgetOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: InspectionBudgetOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for InspectionBudgetOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::InspectionBudget { + type View<'a> = InspectionBudgetView<'a>; + type ViewHandle = InspectionBudgetOwnedView; +} +impl ::serde::Serialize for InspectionBudgetOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// DiagnoseSessionResponse is what the inspection found and, as importantly, +/// what it did not look at. +/// +/// An empty `findings` list means the session is healthy only when every entry +/// in `checks` reports CHECK_STATUS_COMPLETED. A doctor that ran out of budget +/// halfway produces the same empty list as a clean session, and an operator +/// reading only `findings` cannot tell those apart. Which checks ran is +/// therefore part of the answer, not metadata about it. +#[derive(Clone, Debug, Default)] +pub struct DiagnoseSessionResponseView<'a> { + /// Identifies this diagnosis. A repair must name it, so every mutation is + /// traceable to the report that justified it. + /// + /// Field 1: `diagnosis_id` + pub diagnosis_id: &'a str, + /// Field 2: `findings` + pub findings: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::FindingView<'a>, + >, + /// One entry per check the server considered, including checks it skipped. + /// + /// Field 3: `checks` + pub checks: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::CheckOutcomeView<'a>, + >, + /// Field 4: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DiagnoseSessionResponseView<'a> { + /**Whether required field `diagnosis_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_diagnosis_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for DiagnoseSessionResponseView<'a> { + type Owned = super::super::DiagnoseSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.diagnosis_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.findings + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::CheckOutcomeView, + >(), + )?; + view.checks + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::DiagnoseSessionResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::DiagnoseSessionResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DiagnoseSessionResponse { + diagnosis_id: self.diagnosis_id.to_string(), + findings: self + .findings + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + checks: self + .checks + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DiagnoseSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.diagnosis_id) as u64; + for v in &self.findings { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.checks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.diagnosis_id, buf); + for v in &self.findings { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.checks { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DiagnoseSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("diagnosisId", self.diagnosis_id)?; + } + if !self.findings.is_empty() { + __map.serialize_entry("findings", &*self.findings)?; + } + if !self.checks.is_empty() { + __map.serialize_entry("checks", &*self.checks)?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DiagnoseSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DiagnoseSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse"; +} +::buffa::impl_default_view_instance!(DiagnoseSessionResponseView); +::buffa::impl_view_reborrow!(DiagnoseSessionResponseView); +/** Self-contained, `'static` owned view of a `DiagnoseSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`DiagnoseSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DiagnoseSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DiagnoseSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl DiagnoseSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DiagnoseSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DiagnoseSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DiagnoseSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DiagnoseSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DiagnoseSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Identifies this diagnosis. A repair must name it, so every mutation is + /// traceable to the report that justified it. + /// + /// Field 1: `diagnosis_id` + #[must_use] + pub fn diagnosis_id(&self) -> &'_ str { + self.0.reborrow().diagnosis_id + } + /// Field 2: `findings` + #[must_use] + pub fn findings( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::FindingView<'_>> { + &self.0.reborrow().findings + } + /// One entry per check the server considered, including checks it skipped. + /// + /// Field 3: `checks` + #[must_use] + pub fn checks( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::CheckOutcomeView<'_>> { + &self.0.reborrow().checks + } + /// Field 4: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DiagnoseSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DiagnoseSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DiagnoseSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DiagnoseSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DiagnoseSessionResponse { + type View<'a> = DiagnoseSessionResponseView<'a>; + type ViewHandle = DiagnoseSessionResponseOwnedView; +} +impl ::serde::Serialize for DiagnoseSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// CheckOutcome is whether a check actually ran. +#[derive(Clone, Debug, Default)] +pub struct CheckOutcomeView<'a> { + /// Field 1: `check` + pub check: ::buffa::EnumValue, + /// Field 2: `status` + pub status: ::buffa::EnumValue, + /// Field 3: `findings_produced` + pub findings_produced: u32, + /// How far the check got before stopping, in whatever unit it consumes. Only + /// meaningful with BUDGET_EXHAUSTED, where it tells an operator how much + /// larger a budget would need to be. + /// + /// Field 4: `progress` + pub progress: ::core::option::Option, + /// Why a check was skipped or failed. Human-readable, never parsed. + /// + /// Field 5: `reason` + pub reason: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CheckOutcomeView<'a> { + /**Whether required field `check` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_check(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `status` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_status(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `findings_produced` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_findings_produced(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CheckOutcomeView<'a> { + type Owned = super::super::CheckOutcome; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.check = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.findings_produced = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.progress = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CheckOutcome { + check: self.check, + status: self.status, + findings_produced: self.findings_produced, + progress: self.progress, + reason: self.reason.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CheckOutcomeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.check.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.findings_produced) as u64; + if let Some(v) = self.progress { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.check.to_i32(), buf); + ::buffa::types::put_int32_field(2u32, self.status.to_i32(), buf); + ::buffa::types::put_uint32_field(3u32, self.findings_produced, buf); + if let Some(v) = self.progress { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CheckOutcomeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("check", &self.check)?; + } + { + __map.serialize_entry("status", &self.status)?; + } + { + __map + .serialize_entry( + "findingsProduced", + &::buffa::json_helpers::ProtoJson(&self.findings_produced), + )?; + } + if let ::core::option::Option::Some(__v) = self.progress { + __map.serialize_entry("progress", &::buffa::json_helpers::ProtoJson(&__v))?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CheckOutcomeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "CheckOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.CheckOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.CheckOutcome"; +} +::buffa::impl_default_view_instance!(CheckOutcomeView); +::buffa::impl_view_reborrow!(CheckOutcomeView); +/** Self-contained, `'static` owned view of a `CheckOutcome` message. + + Wraps [`::buffa::OwnedView`]`<`[`CheckOutcomeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CheckOutcomeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CheckOutcomeOwnedView(::buffa::OwnedView>); +impl CheckOutcomeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckOutcomeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckOutcomeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CheckOutcome, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckOutcomeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CheckOutcomeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CheckOutcomeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CheckOutcome { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `check` + #[must_use] + pub fn check(&self) -> ::buffa::EnumValue { + self.0.reborrow().check + } + /// Field 2: `status` + #[must_use] + pub fn status(&self) -> ::buffa::EnumValue { + self.0.reborrow().status + } + /// Field 3: `findings_produced` + #[must_use] + pub fn findings_produced(&self) -> u32 { + self.0.reborrow().findings_produced + } + /// How far the check got before stopping, in whatever unit it consumes. Only + /// meaningful with BUDGET_EXHAUSTED, where it tells an operator how much + /// larger a budget would need to be. + /// + /// Field 4: `progress` + #[must_use] + pub fn progress(&self) -> ::core::option::Option { + self.0.reborrow().progress + } + /// Why a check was skipped or failed. Human-readable, never parsed. + /// + /// Field 5: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CheckOutcomeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CheckOutcomeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CheckOutcomeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CheckOutcomeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CheckOutcome { + type View<'a> = CheckOutcomeView<'a>; + type ViewHandle = CheckOutcomeOwnedView; +} +impl ::serde::Serialize for CheckOutcomeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.rs new file mode 100644 index 0000000000..77a571f421 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.diagnose_session.rs @@ -0,0 +1,1299 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/diagnose_session.proto + +/// CheckKind is one family of inspection. Checks are the unit a budget is spent +/// on and the unit completeness is reported against. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum CheckKind { + CHECK_KIND_UNSPECIFIED = 0i32, + /// Stream presence and creation-batch completeness. + CHECK_KIND_STREAM_INTEGRITY = 1i32, + /// Decode every event in range and report the ones that fail. + CHECK_KIND_EVENT_DECODE = 2i32, + /// Fold the stream and confirm it produces a state. + CHECK_KIND_AGGREGATE_REPLAY = 3i32, + /// Compare snapshots against a replay of the events they claim to cover. + CHECK_KIND_SNAPSHOT = 4i32, + /// Projection lag, validity, and checkpoint agreement with the view. + CHECK_KIND_PROJECTION = 5i32, + /// Read artifact content and recompute digests. Not in the default set: its + /// cost is bounded by storage, not by the stream. + CHECK_KIND_ARTIFACT_DIGEST = 6i32, + /// Reserved operations with indeterminate or overdue outcomes. + CHECK_KIND_OPERATION_LEDGER = 7i32, + /// Delegation, detach, and cascade sequences that never terminated, and tool + /// calls stranded in flight. + CHECK_KIND_UNRECONCILED_WORK = 8i32, + /// Recovery checkpoints and their attestations. + CHECK_KIND_CHECKPOINT_ATTESTATION = 9i32, + /// Claims and uploads with no durable owner. Not in the default set: deciding + /// an orphan requires tracing ownership and projector watermarks, which is + /// expensive and must never be approximated by a reference search. + CHECK_KIND_ORPHAN = 10i32, + /// Retention and cold-tier watermarks against what is actually retained. + CHECK_KIND_RETENTION = 11i32, +} +impl CheckKind { + ///Idiomatic alias for [`Self::CHECK_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CHECK_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::CHECK_KIND_STREAM_INTEGRITY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const StreamIntegrity: Self = Self::CHECK_KIND_STREAM_INTEGRITY; + ///Idiomatic alias for [`Self::CHECK_KIND_EVENT_DECODE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const EventDecode: Self = Self::CHECK_KIND_EVENT_DECODE; + ///Idiomatic alias for [`Self::CHECK_KIND_AGGREGATE_REPLAY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AggregateReplay: Self = Self::CHECK_KIND_AGGREGATE_REPLAY; + ///Idiomatic alias for [`Self::CHECK_KIND_SNAPSHOT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Snapshot: Self = Self::CHECK_KIND_SNAPSHOT; + ///Idiomatic alias for [`Self::CHECK_KIND_PROJECTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Projection: Self = Self::CHECK_KIND_PROJECTION; + ///Idiomatic alias for [`Self::CHECK_KIND_ARTIFACT_DIGEST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ArtifactDigest: Self = Self::CHECK_KIND_ARTIFACT_DIGEST; + ///Idiomatic alias for [`Self::CHECK_KIND_OPERATION_LEDGER`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationLedger: Self = Self::CHECK_KIND_OPERATION_LEDGER; + ///Idiomatic alias for [`Self::CHECK_KIND_UNRECONCILED_WORK`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnreconciledWork: Self = Self::CHECK_KIND_UNRECONCILED_WORK; + ///Idiomatic alias for [`Self::CHECK_KIND_CHECKPOINT_ATTESTATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CheckpointAttestation: Self = Self::CHECK_KIND_CHECKPOINT_ATTESTATION; + ///Idiomatic alias for [`Self::CHECK_KIND_ORPHAN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Orphan: Self = Self::CHECK_KIND_ORPHAN; + ///Idiomatic alias for [`Self::CHECK_KIND_RETENTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Retention: Self = Self::CHECK_KIND_RETENTION; +} +impl ::core::default::Default for CheckKind { + fn default() -> Self { + Self::CHECK_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for CheckKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for CheckKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = CheckKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(CheckKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for CheckKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CHECK_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CHECK_KIND_STREAM_INTEGRITY), + 2i32 => ::core::option::Option::Some(Self::CHECK_KIND_EVENT_DECODE), + 3i32 => ::core::option::Option::Some(Self::CHECK_KIND_AGGREGATE_REPLAY), + 4i32 => ::core::option::Option::Some(Self::CHECK_KIND_SNAPSHOT), + 5i32 => ::core::option::Option::Some(Self::CHECK_KIND_PROJECTION), + 6i32 => ::core::option::Option::Some(Self::CHECK_KIND_ARTIFACT_DIGEST), + 7i32 => ::core::option::Option::Some(Self::CHECK_KIND_OPERATION_LEDGER), + 8i32 => ::core::option::Option::Some(Self::CHECK_KIND_UNRECONCILED_WORK), + 9i32 => ::core::option::Option::Some(Self::CHECK_KIND_CHECKPOINT_ATTESTATION), + 10i32 => ::core::option::Option::Some(Self::CHECK_KIND_ORPHAN), + 11i32 => ::core::option::Option::Some(Self::CHECK_KIND_RETENTION), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CHECK_KIND_UNSPECIFIED => "CHECK_KIND_UNSPECIFIED", + Self::CHECK_KIND_STREAM_INTEGRITY => "CHECK_KIND_STREAM_INTEGRITY", + Self::CHECK_KIND_EVENT_DECODE => "CHECK_KIND_EVENT_DECODE", + Self::CHECK_KIND_AGGREGATE_REPLAY => "CHECK_KIND_AGGREGATE_REPLAY", + Self::CHECK_KIND_SNAPSHOT => "CHECK_KIND_SNAPSHOT", + Self::CHECK_KIND_PROJECTION => "CHECK_KIND_PROJECTION", + Self::CHECK_KIND_ARTIFACT_DIGEST => "CHECK_KIND_ARTIFACT_DIGEST", + Self::CHECK_KIND_OPERATION_LEDGER => "CHECK_KIND_OPERATION_LEDGER", + Self::CHECK_KIND_UNRECONCILED_WORK => "CHECK_KIND_UNRECONCILED_WORK", + Self::CHECK_KIND_CHECKPOINT_ATTESTATION => { + "CHECK_KIND_CHECKPOINT_ATTESTATION" + } + Self::CHECK_KIND_ORPHAN => "CHECK_KIND_ORPHAN", + Self::CHECK_KIND_RETENTION => "CHECK_KIND_RETENTION", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CHECK_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CHECK_KIND_UNSPECIFIED) + } + "CHECK_KIND_STREAM_INTEGRITY" => { + ::core::option::Option::Some(Self::CHECK_KIND_STREAM_INTEGRITY) + } + "CHECK_KIND_EVENT_DECODE" => { + ::core::option::Option::Some(Self::CHECK_KIND_EVENT_DECODE) + } + "CHECK_KIND_AGGREGATE_REPLAY" => { + ::core::option::Option::Some(Self::CHECK_KIND_AGGREGATE_REPLAY) + } + "CHECK_KIND_SNAPSHOT" => { + ::core::option::Option::Some(Self::CHECK_KIND_SNAPSHOT) + } + "CHECK_KIND_PROJECTION" => { + ::core::option::Option::Some(Self::CHECK_KIND_PROJECTION) + } + "CHECK_KIND_ARTIFACT_DIGEST" => { + ::core::option::Option::Some(Self::CHECK_KIND_ARTIFACT_DIGEST) + } + "CHECK_KIND_OPERATION_LEDGER" => { + ::core::option::Option::Some(Self::CHECK_KIND_OPERATION_LEDGER) + } + "CHECK_KIND_UNRECONCILED_WORK" => { + ::core::option::Option::Some(Self::CHECK_KIND_UNRECONCILED_WORK) + } + "CHECK_KIND_CHECKPOINT_ATTESTATION" => { + ::core::option::Option::Some(Self::CHECK_KIND_CHECKPOINT_ATTESTATION) + } + "CHECK_KIND_ORPHAN" => ::core::option::Option::Some(Self::CHECK_KIND_ORPHAN), + "CHECK_KIND_RETENTION" => { + ::core::option::Option::Some(Self::CHECK_KIND_RETENTION) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CHECK_KIND_UNSPECIFIED, + Self::CHECK_KIND_STREAM_INTEGRITY, + Self::CHECK_KIND_EVENT_DECODE, + Self::CHECK_KIND_AGGREGATE_REPLAY, + Self::CHECK_KIND_SNAPSHOT, + Self::CHECK_KIND_PROJECTION, + Self::CHECK_KIND_ARTIFACT_DIGEST, + Self::CHECK_KIND_OPERATION_LEDGER, + Self::CHECK_KIND_UNRECONCILED_WORK, + Self::CHECK_KIND_CHECKPOINT_ATTESTATION, + Self::CHECK_KIND_ORPHAN, + Self::CHECK_KIND_RETENTION, + ] + } +} +/// CheckStatus is how a check ended. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum CheckStatus { + CHECK_STATUS_UNSPECIFIED = 0i32, + /// Ran to completion. Its findings, including none, are conclusive. + CHECK_STATUS_COMPLETED = 1i32, + /// Ran and stopped early against the budget. Its findings are real; their + /// absence proves nothing. + CHECK_STATUS_BUDGET_EXHAUSTED = 2i32, + /// Not requested, or not applicable to this session. + CHECK_STATUS_SKIPPED = 3i32, + /// The check itself failed. Reported rather than swallowed: a diagnostic that + /// hides its own failures is worse than no diagnostic, because it is trusted. + CHECK_STATUS_FAILED = 4i32, +} +impl CheckStatus { + ///Idiomatic alias for [`Self::CHECK_STATUS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CHECK_STATUS_UNSPECIFIED; + ///Idiomatic alias for [`Self::CHECK_STATUS_COMPLETED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Completed: Self = Self::CHECK_STATUS_COMPLETED; + ///Idiomatic alias for [`Self::CHECK_STATUS_BUDGET_EXHAUSTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const BudgetExhausted: Self = Self::CHECK_STATUS_BUDGET_EXHAUSTED; + ///Idiomatic alias for [`Self::CHECK_STATUS_SKIPPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Skipped: Self = Self::CHECK_STATUS_SKIPPED; + ///Idiomatic alias for [`Self::CHECK_STATUS_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::CHECK_STATUS_FAILED; +} +impl ::core::default::Default for CheckStatus { + fn default() -> Self { + Self::CHECK_STATUS_UNSPECIFIED + } +} +impl ::serde::Serialize for CheckStatus { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for CheckStatus { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = CheckStatus; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(CheckStatus)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckStatus { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for CheckStatus { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CHECK_STATUS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CHECK_STATUS_COMPLETED), + 2i32 => ::core::option::Option::Some(Self::CHECK_STATUS_BUDGET_EXHAUSTED), + 3i32 => ::core::option::Option::Some(Self::CHECK_STATUS_SKIPPED), + 4i32 => ::core::option::Option::Some(Self::CHECK_STATUS_FAILED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CHECK_STATUS_UNSPECIFIED => "CHECK_STATUS_UNSPECIFIED", + Self::CHECK_STATUS_COMPLETED => "CHECK_STATUS_COMPLETED", + Self::CHECK_STATUS_BUDGET_EXHAUSTED => "CHECK_STATUS_BUDGET_EXHAUSTED", + Self::CHECK_STATUS_SKIPPED => "CHECK_STATUS_SKIPPED", + Self::CHECK_STATUS_FAILED => "CHECK_STATUS_FAILED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CHECK_STATUS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CHECK_STATUS_UNSPECIFIED) + } + "CHECK_STATUS_COMPLETED" => { + ::core::option::Option::Some(Self::CHECK_STATUS_COMPLETED) + } + "CHECK_STATUS_BUDGET_EXHAUSTED" => { + ::core::option::Option::Some(Self::CHECK_STATUS_BUDGET_EXHAUSTED) + } + "CHECK_STATUS_SKIPPED" => { + ::core::option::Option::Some(Self::CHECK_STATUS_SKIPPED) + } + "CHECK_STATUS_FAILED" => { + ::core::option::Option::Some(Self::CHECK_STATUS_FAILED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CHECK_STATUS_UNSPECIFIED, + Self::CHECK_STATUS_COMPLETED, + Self::CHECK_STATUS_BUDGET_EXHAUSTED, + Self::CHECK_STATUS_SKIPPED, + Self::CHECK_STATUS_FAILED, + ] + } +} +/// DiagnoseSessionRequest inspects one session and reports what disagrees. +/// +/// This operation mutates nothing. It is not a mode of a repair operation and it +/// has no flag that would make it one, because a report-only default that lives +/// in a field is one typo away from not being the default. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DiagnoseSessionRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Checks to run. Empty runs the default set, which excludes the checks whose + /// cost scales with artifact storage rather than with the stream. + /// + /// Field 2: `checks` + #[serde( + rename = "checks", + with = "::buffa::json_helpers::repeated_enum", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec" + )] + pub checks: ::buffa::alloc::vec::Vec<::buffa::EnumValue>, + /// Field 3: `budget` + #[serde( + rename = "budget", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub budget: ::buffa::MessageField< + InspectionBudget, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for DiagnoseSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DiagnoseSessionRequest") + .field("session_id", &self.session_id) + .field("checks", &self.checks) + .field("budget", &self.budget) + .finish() + } +} +impl DiagnoseSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest"; +} +::buffa::impl_default_instance!(DiagnoseSessionRequest); +impl ::buffa::MessageName for DiagnoseSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DiagnoseSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest"; +} +impl ::buffa::Message for DiagnoseSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if !self.checks.is_empty() { + let payload: u64 = self + .checks + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.budget.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.budget.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if !self.checks.is_empty() { + let payload: u64 = self + .checks + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(2u32, payload, buf); + for v in &self.checks { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.budget.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.budget.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = usize::try_from(len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + self.checks.reserve(len); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.checks + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut limited)?, + ), + ); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + self.checks + .push( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } else { + return ::core::result::Result::Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.budget.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.checks.clear(); + self.budget = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DiagnoseSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DIAGNOSE_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// InspectionBudget bounds the work a diagnosis may do. +/// +/// Inspection is unbounded by nature: verifying every artifact digest on a long +/// session means reading every artifact. Without a budget the doctor becomes a +/// load generator that operators learn not to run, and a diagnostic nobody dares +/// use is worth nothing. +/// +/// Unset fields mean the server's default, not unlimited. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct InspectionBudget { + /// Field 1: `max_events_scanned` + #[serde( + rename = "maxEventsScanned", + alias = "max_events_scanned", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_events_scanned: ::core::option::Option, + /// Field 2: `max_artifacts_verified` + #[serde( + rename = "maxArtifactsVerified", + alias = "max_artifacts_verified", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_artifacts_verified: ::core::option::Option, + /// Field 3: `max_duration` + #[serde( + rename = "maxDuration", + alias = "max_duration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub max_duration: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for InspectionBudget { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("InspectionBudget") + .field("max_events_scanned", &self.max_events_scanned) + .field("max_artifacts_verified", &self.max_artifacts_verified) + .field("max_duration", &self.max_duration) + .finish() + } +} +impl InspectionBudget { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.InspectionBudget"; +} +impl InspectionBudget { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_events_scanned`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_events_scanned(mut self, value: u64) -> Self { + self.max_events_scanned = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_artifacts_verified`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_artifacts_verified(mut self, value: u64) -> Self { + self.max_artifacts_verified = Some(value); + self + } +} +::buffa::impl_default_instance!(InspectionBudget); +impl ::buffa::MessageName for InspectionBudget { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "InspectionBudget"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.InspectionBudget"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.InspectionBudget"; +} +impl ::buffa::Message for InspectionBudget { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_events_scanned { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_artifacts_verified { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_events_scanned { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_artifacts_verified { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_events_scanned = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_artifacts_verified = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.max_duration.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.max_events_scanned = ::core::option::Option::None; + self.max_artifacts_verified = ::core::option::Option::None; + self.max_duration = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for InspectionBudget { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __INSPECTION_BUDGET_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.InspectionBudget", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// DiagnoseSessionResponse is what the inspection found and, as importantly, +/// what it did not look at. +/// +/// An empty `findings` list means the session is healthy only when every entry +/// in `checks` reports CHECK_STATUS_COMPLETED. A doctor that ran out of budget +/// halfway produces the same empty list as a clean session, and an operator +/// reading only `findings` cannot tell those apart. Which checks ran is +/// therefore part of the answer, not metadata about it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DiagnoseSessionResponse { + /// Identifies this diagnosis. A repair must name it, so every mutation is + /// traceable to the report that justified it. + /// + /// Field 1: `diagnosis_id` + #[serde( + rename = "diagnosisId", + alias = "diagnosis_id", + with = "::buffa::json_helpers::proto_string" + )] + pub diagnosis_id: ::buffa::alloc::string::String, + /// Field 2: `findings` + #[serde( + rename = "findings", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub findings: ::buffa::alloc::vec::Vec, + /// One entry per check the server considered, including checks it skipped. + /// + /// Field 3: `checks` + #[serde( + rename = "checks", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub checks: ::buffa::alloc::vec::Vec, + /// Field 4: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for DiagnoseSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DiagnoseSessionResponse") + .field("diagnosis_id", &self.diagnosis_id) + .field("findings", &self.findings) + .field("checks", &self.checks) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl DiagnoseSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse"; +} +::buffa::impl_default_instance!(DiagnoseSessionResponse); +impl ::buffa::MessageName for DiagnoseSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DiagnoseSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse"; +} +impl ::buffa::Message for DiagnoseSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.diagnosis_id) as u64; + for v in &self.findings { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.checks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.diagnosis_id, buf); + for v in &self.findings { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.checks { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.diagnosis_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.findings.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.checks.push(elem); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.diagnosis_id.clear(); + self.findings.clear(); + self.checks.clear(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DiagnoseSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DIAGNOSE_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DiagnoseSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// CheckOutcome is whether a check actually ran. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CheckOutcome { + /// Field 1: `check` + #[serde(rename = "check", with = "::buffa::json_helpers::proto_enum")] + pub check: ::buffa::EnumValue, + /// Field 2: `status` + #[serde(rename = "status", with = "::buffa::json_helpers::proto_enum")] + pub status: ::buffa::EnumValue, + /// Field 3: `findings_produced` + #[serde( + rename = "findingsProduced", + alias = "findings_produced", + with = "::buffa::json_helpers::uint32" + )] + pub findings_produced: u32, + /// How far the check got before stopping, in whatever unit it consumes. Only + /// meaningful with BUDGET_EXHAUSTED, where it tells an operator how much + /// larger a budget would need to be. + /// + /// Field 4: `progress` + #[serde( + rename = "progress", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub progress: ::core::option::Option, + /// Why a check was skipped or failed. Human-readable, never parsed. + /// + /// Field 5: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for CheckOutcome { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CheckOutcome") + .field("check", &self.check) + .field("status", &self.status) + .field("findings_produced", &self.findings_produced) + .field("progress", &self.progress) + .field("reason", &self.reason) + .finish() + } +} +impl CheckOutcome { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.CheckOutcome"; +} +impl CheckOutcome { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::progress`] to `Some(value)`, consuming and returning `self`. + pub fn with_progress(mut self, value: u64) -> Self { + self.progress = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(CheckOutcome); +impl ::buffa::MessageName for CheckOutcome { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "CheckOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.CheckOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.CheckOutcome"; +} +impl ::buffa::Message for CheckOutcome { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.check.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.findings_produced) as u64; + if let Some(v) = self.progress { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.check.to_i32(), buf); + ::buffa::types::put_int32_field(2u32, self.status.to_i32(), buf); + ::buffa::types::put_uint32_field(3u32, self.findings_produced, buf); + if let Some(v) = self.progress { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.check = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.findings_produced = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.progress = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.check = ::buffa::EnumValue::from(0); + self.status = ::buffa::EnumValue::from(0); + self.findings_produced = 0u32; + self.progress = ::core::option::Option::None; + self.reason = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CHECK_OUTCOME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.CheckOutcome", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.__view.rs new file mode 100644 index 0000000000..529a8554d8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.__view.rs @@ -0,0 +1,323 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/doctor_error.proto + +/// DoctorError is the typed failure payload for the doctor surface. +/// +/// Defined here rather than shared with the query contract's QueryError. The +/// doctor is an operator surface with its own audience and its own release +/// cadence, and pinning its failure vocabulary to a client-facing contract would +/// mean every new operator diagnostic is a client-visible change. That is the +/// same reasoning the query contract applies to projection value types, one +/// subtree further out. +#[derive(Clone, Debug, Default)] +pub struct DoctorErrorView<'a> { + /// Field 1: `code` + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + pub message: &'a str, + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + pub field_path: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DoctorErrorView<'a> { + /**Whether required field `code` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_code(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DoctorErrorView<'a> { + type Owned = super::super::DoctorError; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.code = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.field_path = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DoctorError { + code: self.code, + message: self.message.to_string(), + field_path: self.field_path.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DoctorErrorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let Some(ref v) = self.field_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let Some(ref v) = self.field_path { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DoctorErrorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("code", &self.code)?; + } + { + __map.serialize_entry("message", self.message)?; + } + if let ::core::option::Option::Some(__v) = self.field_path { + __map.serialize_entry("fieldPath", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DoctorErrorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DoctorError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DoctorError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DoctorError"; +} +::buffa::impl_default_view_instance!(DoctorErrorView); +::buffa::impl_view_reborrow!(DoctorErrorView); +/** Self-contained, `'static` owned view of a `DoctorError` message. + + Wraps [`::buffa::OwnedView`]`<`[`DoctorErrorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DoctorErrorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DoctorErrorOwnedView(::buffa::OwnedView>); +impl DoctorErrorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DoctorErrorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DoctorErrorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DoctorError, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DoctorErrorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DoctorErrorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DoctorErrorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DoctorError { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `code` + #[must_use] + pub fn code(&self) -> ::buffa::EnumValue { + self.0.reborrow().code + } + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + #[must_use] + pub fn message(&self) -> &'_ str { + self.0.reborrow().message + } + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + #[must_use] + pub fn field_path(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().field_path + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DoctorErrorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DoctorErrorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DoctorErrorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DoctorErrorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DoctorError { + type View<'a> = DoctorErrorView<'a>; + type ViewHandle = DoctorErrorOwnedView; +} +impl ::serde::Serialize for DoctorErrorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.rs new file mode 100644 index 0000000000..90e91c8c93 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.doctor_error.rs @@ -0,0 +1,430 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/doctor_error.proto + +/// DoctorErrorCode is why a diagnosis or repair could not be served. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum DoctorErrorCode { + DOCTOR_ERROR_CODE_UNSPECIFIED = 0i32, + DOCTOR_ERROR_CODE_SESSION_NOT_FOUND = 1i32, + DOCTOR_ERROR_CODE_INVALID_ARGUMENT = 2i32, + /// The repair names a diagnosis this server does not have. Repairs are bound + /// to a report, so an unknown one is refused rather than treated as an + /// unprovenanced repair. + DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND = 3i32, + /// The diagnosis is known and too old to authorize a mutation. A report ages + /// into a description of a session that no longer exists, and re-verification + /// catches most of that but should not be the only thing standing between a + /// stale report and a destructive action. + DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED = 4i32, + /// The repair names findings from a different session than it targets. + DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH = 5i32, + /// The caller may not inspect or repair this session. Diagnosis and repair are + /// authorized separately: read access to a report does not carry the right to + /// act on it. + DOCTOR_ERROR_CODE_PERMISSION_DENIED = 6i32, + /// The requested inspection is too expensive to admit even with a budget. + DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED = 7i32, + DOCTOR_ERROR_CODE_INTERNAL = 8i32, +} +impl DoctorErrorCode { + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::DOCTOR_ERROR_CODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SessionNotFound: Self = Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InvalidArgument: Self = Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DiagnosisNotFound: Self = Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DiagnosisExpired: Self = Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DiagnosisSessionMismatch: Self = Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PermissionDenied: Self = Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ResourceExhausted: Self = Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED; + ///Idiomatic alias for [`Self::DOCTOR_ERROR_CODE_INTERNAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Internal: Self = Self::DOCTOR_ERROR_CODE_INTERNAL; +} +impl ::core::default::Default for DoctorErrorCode { + fn default() -> Self { + Self::DOCTOR_ERROR_CODE_UNSPECIFIED + } +} +impl ::serde::Serialize for DoctorErrorCode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for DoctorErrorCode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = DoctorErrorCode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(DoctorErrorCode) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for DoctorErrorCode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for DoctorErrorCode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND) + } + 2i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT) + } + 3i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND) + } + 4i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED) + } + 5i32 => { + ::core::option::Option::Some( + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH, + ) + } + 6i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED) + } + 7i32 => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED) + } + 8i32 => ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_INTERNAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::DOCTOR_ERROR_CODE_UNSPECIFIED => "DOCTOR_ERROR_CODE_UNSPECIFIED", + Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND => { + "DOCTOR_ERROR_CODE_SESSION_NOT_FOUND" + } + Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT => { + "DOCTOR_ERROR_CODE_INVALID_ARGUMENT" + } + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND => { + "DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND" + } + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED => { + "DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED" + } + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH => { + "DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH" + } + Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED => { + "DOCTOR_ERROR_CODE_PERMISSION_DENIED" + } + Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED => { + "DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED" + } + Self::DOCTOR_ERROR_CODE_INTERNAL => "DOCTOR_ERROR_CODE_INTERNAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "DOCTOR_ERROR_CODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_UNSPECIFIED) + } + "DOCTOR_ERROR_CODE_SESSION_NOT_FOUND" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND) + } + "DOCTOR_ERROR_CODE_INVALID_ARGUMENT" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT) + } + "DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND) + } + "DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED) + } + "DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH" => { + ::core::option::Option::Some( + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH, + ) + } + "DOCTOR_ERROR_CODE_PERMISSION_DENIED" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED) + } + "DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED) + } + "DOCTOR_ERROR_CODE_INTERNAL" => { + ::core::option::Option::Some(Self::DOCTOR_ERROR_CODE_INTERNAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::DOCTOR_ERROR_CODE_UNSPECIFIED, + Self::DOCTOR_ERROR_CODE_SESSION_NOT_FOUND, + Self::DOCTOR_ERROR_CODE_INVALID_ARGUMENT, + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_NOT_FOUND, + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_EXPIRED, + Self::DOCTOR_ERROR_CODE_DIAGNOSIS_SESSION_MISMATCH, + Self::DOCTOR_ERROR_CODE_PERMISSION_DENIED, + Self::DOCTOR_ERROR_CODE_RESOURCE_EXHAUSTED, + Self::DOCTOR_ERROR_CODE_INTERNAL, + ] + } +} +/// DoctorError is the typed failure payload for the doctor surface. +/// +/// Defined here rather than shared with the query contract's QueryError. The +/// doctor is an operator surface with its own audience and its own release +/// cadence, and pinning its failure vocabulary to a client-facing contract would +/// mean every new operator diagnostic is a client-visible change. That is the +/// same reasoning the query contract applies to projection value types, one +/// subtree further out. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DoctorError { + /// Field 1: `code` + #[serde(rename = "code", with = "::buffa::json_helpers::proto_enum")] + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + #[serde(rename = "message", with = "::buffa::json_helpers::proto_string")] + pub message: ::buffa::alloc::string::String, + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + #[serde( + rename = "fieldPath", + alias = "field_path", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub field_path: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for DoctorError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DoctorError") + .field("code", &self.code) + .field("message", &self.message) + .field("field_path", &self.field_path) + .finish() + } +} +impl DoctorError { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DoctorError"; +} +impl DoctorError { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::field_path`] to `Some(value)`, consuming and returning `self`. + pub fn with_field_path( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.field_path = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DoctorError); +impl ::buffa::MessageName for DoctorError { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "DoctorError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.DoctorError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DoctorError"; +} +impl ::buffa::Message for DoctorError { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let Some(ref v) = self.field_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let Some(ref v) = self.field_path { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.code = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .field_path + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.code = ::buffa::EnumValue::from(0); + self.message.clear(); + self.field_path = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DoctorError { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DOCTOR_ERROR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.DoctorError", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__oneof.rs new file mode 100644 index 0000000000..f332fcd07a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__oneof.rs @@ -0,0 +1,123 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/finding.proto + +pub mod finding { + #[allow(unused_imports)] + use super::*; + /// Machine-readable specifics. `kind` sits outside this union on purpose: an + /// unset oneof and a variant added after the reader was built are + /// indistinguishable, so the kind is what stays readable either way. + #[derive(Clone, PartialEq, Debug)] + pub enum Detail { + EventDecode(::buffa::alloc::boxed::Box), + ProjectionCheckpoint( + ::buffa::alloc::boxed::Box, + ), + ArtifactDigest( + ::buffa::alloc::boxed::Box, + ), + OperationLedger( + ::buffa::alloc::boxed::Box, + ), + UnreconciledWork( + ::buffa::alloc::boxed::Box, + ), + Orphan(::buffa::alloc::boxed::Box), + } + impl ::buffa::Oneof for Detail {} + impl From for Detail { + fn from(v: super::super::super::EventDecodeDetail) -> Self { + Self::EventDecode(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::EventDecodeDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::ProjectionCheckpointDetail) -> Self { + Self::ProjectionCheckpoint(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::ProjectionCheckpointDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::ArtifactDigestDetail) -> Self { + Self::ArtifactDigest(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::ArtifactDigestDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::OperationLedgerDetail) -> Self { + Self::OperationLedger(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::OperationLedgerDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::UnreconciledWorkDetail) -> Self { + Self::UnreconciledWork(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::UnreconciledWorkDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::OrphanDetail) -> Self { + Self::Orphan(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::OrphanDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl serde::Serialize for Detail { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::EventDecode(v) => { + map.serialize_entry("eventDecode", v)?; + } + Self::ProjectionCheckpoint(v) => { + map.serialize_entry("projectionCheckpoint", v)?; + } + Self::ArtifactDigest(v) => { + map.serialize_entry("artifactDigest", v)?; + } + Self::OperationLedger(v) => { + map.serialize_entry("operationLedger", v)?; + } + Self::UnreconciledWork(v) => { + map.serialize_entry("unreconciledWork", v)?; + } + Self::Orphan(v) => { + map.serialize_entry("orphan", v)?; + } + } + map.end() + } + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view.rs new file mode 100644 index 0000000000..3d9475cb15 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view.rs @@ -0,0 +1,3240 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/finding.proto + +/// Finding is one inconsistency the doctor observed. +/// +/// A finding is an observation, never an instruction. It says what disagrees +/// with what, and it names the repairs that could address it, but producing one +/// mutates nothing. That separation is the whole design: diagnosis and repair are +/// different operations with different messages, so a caller cannot reach a +/// mutation by filling in one more field on a read. +#[derive(Clone, Debug, Default)] +pub struct FindingView<'a> { + /// Stable identity for this problem: a digest over `kind` and `subject`. + /// + /// Deliberately not a digest over the observed values. A projection that falls + /// further behind between diagnosis and repair is still the same finding, and + /// an id that changed with every observed byte would make repairs impossible on + /// a busy session. Staleness is caught by re-verifying the finding at repair + /// time, not by comparing ids. + /// + /// Field 1: `finding_id` + pub finding_id: &'a str, + /// Field 2: `kind` + pub kind: ::buffa::EnumValue, + /// Field 3: `severity` + pub severity: ::buffa::EnumValue, + /// Field 4: `subject` + pub subject: ::buffa::MessageFieldView< + super::super::__buffa::view::SubjectRefView<'a>, + >, + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 5: `summary` + pub summary: &'a str, + /// Repairs that could address this finding, and the only actions a + /// RepairSessionRequest may name for it. An empty list means nothing the + /// doctor can do will help, which is the normal case for a CORRUPT finding. + /// + /// Field 6: `available_repairs` + pub available_repairs: ::buffa::RepeatedView< + 'a, + ::buffa::EnumValue, + >, + /// Field 7: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + pub detail: ::core::option::Option< + super::super::__buffa::view::oneof::finding::Detail<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> FindingView<'a> { + /**Whether required field `finding_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_finding_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `severity` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_severity(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `subject` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_subject(&self) -> bool { + self.subject.is_set() + } + /**Whether required field `summary` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for FindingView<'a> { + type Owned = super::super::Finding; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.finding_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.severity = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.subject.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.subject = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.summary = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let payload = ::buffa::types::borrow_bytes(&mut cur)?; + view.available_repairs + .reserve(::buffa::encoding::count_varints(payload)); + let mut pcur: &[u8] = payload; + while !pcur.is_empty() { + view.available_repairs + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut pcur)?, + ), + ); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + view.available_repairs + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ), + ); + } else { + return Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::EventDecode( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::EventDecode( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::finding::Detail::Orphan( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::finding::Detail::Orphan( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::Finding { + finding_id: self.finding_id.to_string(), + kind: self.kind, + severity: self.severity, + subject: match self.subject.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SubjectRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + summary: self.summary.to_string(), + available_repairs: self.available_repairs.to_vec(), + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detail: match self.detail.as_ref() { + ::core::option::Option::Some(v) => { + ::core::option::Option::Some( + match v { + super::super::__buffa::view::oneof::finding::Detail::EventDecode( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::EventDecode( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::ProjectionCheckpoint( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::ArtifactDigest( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::OperationLedger( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::UnreconciledWork( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::finding::Detail::Orphan( + v, + ) => { + super::super::__buffa::oneof::finding::Detail::Orphan( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + }, + ) + } + ::core::option::Option::None => ::core::option::Option::None, + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for FindingView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.severity.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.subject.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.subject.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary) as u64; + if !self.available_repairs.is_empty() { + let payload: u64 = self + .available_repairs + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + super::super::__buffa::view::oneof::finding::Detail::EventDecode(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::finding::Detail::Orphan(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + ::buffa::types::put_int32_field(3u32, self.severity.to_i32(), buf); + if self.subject.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.subject.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.summary, buf); + if !self.available_repairs.is_empty() { + let payload: u64 = self + .available_repairs + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(6u32, payload, buf); + for v in &self.available_repairs { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + super::super::__buffa::view::oneof::finding::Detail::EventDecode(x) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::finding::Detail::Orphan(x) => { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for FindingView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("findingId", self.finding_id)?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + { + __map.serialize_entry("severity", &self.severity)?; + } + { + if let ::core::option::Option::Some(__v) = self.subject.as_option() { + __map.serialize_entry("subject", __v)?; + } + } + { + __map.serialize_entry("summary", self.summary)?; + } + if !self.available_repairs.is_empty() { + __map + .serialize_entry( + "availableRepairs", + &::buffa::json_helpers::EnumSeqJson(&self.available_repairs), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + if let ::core::option::Option::Some(ref __ov) = self.detail { + match __ov { + super::super::__buffa::view::oneof::finding::Detail::EventDecode(v) => { + __map.serialize_entry("eventDecode", v)?; + } + super::super::__buffa::view::oneof::finding::Detail::ProjectionCheckpoint( + v, + ) => { + __map.serialize_entry("projectionCheckpoint", v)?; + } + super::super::__buffa::view::oneof::finding::Detail::ArtifactDigest( + v, + ) => { + __map.serialize_entry("artifactDigest", v)?; + } + super::super::__buffa::view::oneof::finding::Detail::OperationLedger( + v, + ) => { + __map.serialize_entry("operationLedger", v)?; + } + super::super::__buffa::view::oneof::finding::Detail::UnreconciledWork( + v, + ) => { + __map.serialize_entry("unreconciledWork", v)?; + } + super::super::__buffa::view::oneof::finding::Detail::Orphan(v) => { + __map.serialize_entry("orphan", v)?; + } + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for FindingView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "Finding"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.Finding"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.Finding"; +} +::buffa::impl_default_view_instance!(FindingView); +::buffa::impl_view_reborrow!(FindingView); +/** Self-contained, `'static` owned view of a `Finding` message. + + Wraps [`::buffa::OwnedView`]`<`[`FindingView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FindingView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct FindingOwnedView(::buffa::OwnedView>); +impl FindingOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(FindingOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FindingOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::Finding, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FindingOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`FindingView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &FindingView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::Finding { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Stable identity for this problem: a digest over `kind` and `subject`. + /// + /// Deliberately not a digest over the observed values. A projection that falls + /// further behind between diagnosis and repair is still the same finding, and + /// an id that changed with every observed byte would make repairs impossible on + /// a busy session. Staleness is caught by re-verifying the finding at repair + /// time, not by comparing ids. + /// + /// Field 1: `finding_id` + #[must_use] + pub fn finding_id(&self) -> &'_ str { + self.0.reborrow().finding_id + } + /// Field 2: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Field 3: `severity` + #[must_use] + pub fn severity(&self) -> ::buffa::EnumValue { + self.0.reborrow().severity + } + /// Field 4: `subject` + #[must_use] + pub fn subject( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().subject + } + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 5: `summary` + #[must_use] + pub fn summary(&self) -> &'_ str { + self.0.reborrow().summary + } + /// Repairs that could address this finding, and the only actions a + /// RepairSessionRequest may name for it. An empty list means nothing the + /// doctor can do will help, which is the normal case for a CORRUPT finding. + /// + /// Field 6: `available_repairs` + #[must_use] + pub fn available_repairs( + &self, + ) -> &::buffa::RepeatedView<'_, ::buffa::EnumValue> { + &self.0.reborrow().available_repairs + } + /// Field 7: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } + /// Oneof `detail`. + #[must_use] + pub fn detail( + &self, + ) -> ::core::option::Option< + &super::super::__buffa::view::oneof::finding::Detail<'_>, + > { + self.0.reborrow().detail.as_ref() + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for FindingOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + FindingOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: FindingOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for FindingOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::Finding { + type View<'a> = FindingView<'a>; + type ViewHandle = FindingOwnedView; +} +impl ::serde::Serialize for FindingOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SubjectRef says what a finding is about. +/// +/// `kind` is what gives `entity_id` meaning, and the pair travels together for +/// that reason: an id with no idea what it identifies is not a reference. +#[derive(Clone, Debug, Default)] +pub struct SubjectRefView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `kind` + pub kind: ::buffa::EnumValue, + /// Interpreted according to `kind`: an artifact id, an operation id, a tool + /// execution id, a projection name. Unset when `kind` is STREAM, which needs + /// no further identity than the session. + /// + /// Field 3: `entity_id` + pub entity_id: ::core::option::Option<&'a str>, + /// The SessionOrdinal the finding is anchored at. Unset when the finding is + /// not ordinal-scoped, which is not the same as ordinal zero. + /// + /// Field 4: `ordinal` + pub ordinal: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SubjectRefView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SubjectRefView<'a> { + type Owned = super::super::SubjectRef; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.entity_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = Some(::buffa::types::decode_uint64(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SubjectRef { + session_id: self.session_id.to_string(), + kind: self.kind, + entity_id: self.entity_id.map(|s| s.to_string()), + ordinal: self.ordinal, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SubjectRefView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.entity_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.entity_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(v) = self.ordinal { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SubjectRefView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(__v) = self.entity_id { + __map.serialize_entry("entityId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.ordinal { + __map.serialize_entry("ordinal", &::buffa::json_helpers::ProtoJson(&__v))?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SubjectRefView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "SubjectRef"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.SubjectRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.SubjectRef"; +} +::buffa::impl_default_view_instance!(SubjectRefView); +::buffa::impl_view_reborrow!(SubjectRefView); +/** Self-contained, `'static` owned view of a `SubjectRef` message. + + Wraps [`::buffa::OwnedView`]`<`[`SubjectRefView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SubjectRefView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SubjectRefOwnedView(::buffa::OwnedView>); +impl SubjectRefOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SubjectRefOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SubjectRefOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SubjectRef, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SubjectRefOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SubjectRefView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SubjectRefView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SubjectRef { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Interpreted according to `kind`: an artifact id, an operation id, a tool + /// execution id, a projection name. Unset when `kind` is STREAM, which needs + /// no further identity than the session. + /// + /// Field 3: `entity_id` + #[must_use] + pub fn entity_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().entity_id + } + /// The SessionOrdinal the finding is anchored at. Unset when the finding is + /// not ordinal-scoped, which is not the same as ordinal zero. + /// + /// Field 4: `ordinal` + #[must_use] + pub fn ordinal(&self) -> ::core::option::Option { + self.0.reborrow().ordinal + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SubjectRefOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SubjectRefOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SubjectRefOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SubjectRefOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SubjectRef { + type View<'a> = SubjectRefView<'a>; + type ViewHandle = SubjectRefOwnedView; +} +impl ::serde::Serialize for SubjectRefOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// EventDecodeDetail is enough to find the offending event without re-running +/// the scan. +#[derive(Clone, Debug, Default)] +pub struct EventDecodeDetailView<'a> { + /// Field 1: `ordinal` + pub ordinal: u64, + /// Field 2: `type_url` + pub type_url: &'a str, + /// Decoder error text. Diagnostic only, never parsed. + /// + /// Field 3: `decoder_error` + pub decoder_error: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> EventDecodeDetailView<'a> { + /**Whether required field `ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `type_url` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_type_url(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `decoder_error` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_decoder_error(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for EventDecodeDetailView<'a> { + type Owned = super::super::EventDecodeDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.type_url = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.decoder_error = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::EventDecodeDetail { + ordinal: self.ordinal, + type_url: self.type_url.to_string(), + decoder_error: self.decoder_error.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for EventDecodeDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.type_url) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.decoder_error) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.ordinal, buf); + ::buffa::types::put_string_field(2u32, &self.type_url, buf); + ::buffa::types::put_string_field(3u32, &self.decoder_error, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for EventDecodeDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "ordinal", + &::buffa::json_helpers::ProtoJson(&self.ordinal), + )?; + } + { + __map.serialize_entry("typeUrl", self.type_url)?; + } + { + __map.serialize_entry("decoderError", self.decoder_error)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for EventDecodeDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "EventDecodeDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail"; +} +::buffa::impl_default_view_instance!(EventDecodeDetailView); +::buffa::impl_view_reborrow!(EventDecodeDetailView); +/** Self-contained, `'static` owned view of a `EventDecodeDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`EventDecodeDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`EventDecodeDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct EventDecodeDetailOwnedView( + ::buffa::OwnedView>, +); +impl EventDecodeDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EventDecodeDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EventDecodeDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::EventDecodeDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EventDecodeDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`EventDecodeDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &EventDecodeDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::EventDecodeDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `ordinal` + #[must_use] + pub fn ordinal(&self) -> u64 { + self.0.reborrow().ordinal + } + /// Field 2: `type_url` + #[must_use] + pub fn type_url(&self) -> &'_ str { + self.0.reborrow().type_url + } + /// Decoder error text. Diagnostic only, never parsed. + /// + /// Field 3: `decoder_error` + #[must_use] + pub fn decoder_error(&self) -> &'_ str { + self.0.reborrow().decoder_error + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for EventDecodeDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + EventDecodeDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: EventDecodeDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for EventDecodeDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::EventDecodeDetail { + type View<'a> = EventDecodeDetailView<'a>; + type ViewHandle = EventDecodeDetailOwnedView; +} +impl ::serde::Serialize for EventDecodeDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ProjectionCheckpointDetail carries the three positions whose disagreement is +/// the finding, because a checkpoint inconsistency is unreadable without all +/// three. +#[derive(Clone, Debug, Default)] +pub struct ProjectionCheckpointDetailView<'a> { + /// Field 1: `projection_name` + pub projection_name: &'a str, + /// Field 2: `projection_generation` + pub projection_generation: &'a str, + /// What the checkpoint claims was applied. + /// + /// Field 3: `checkpoint_watermark` + pub checkpoint_watermark: u64, + /// What the materialized view actually reflects. Below the checkpoint means + /// the checkpoint is lying about work the view never received. + /// + /// Field 4: `view_applied_through` + pub view_applied_through: u64, + /// The source head. Below the checkpoint means the checkpoint refers to + /// history this stream does not have. + /// + /// Field 5: `source_high_watermark` + pub source_high_watermark: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProjectionCheckpointDetailView<'a> { + /**Whether required field `projection_name` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projection_name(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `projection_generation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projection_generation(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `checkpoint_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_checkpoint_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `view_applied_through` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_view_applied_through(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `source_high_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_high_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ProjectionCheckpointDetailView<'a> { + type Owned = super::super::ProjectionCheckpointDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.projection_name = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.projection_generation = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.checkpoint_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.view_applied_through = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source_high_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ProjectionCheckpointDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ProjectionCheckpointDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProjectionCheckpointDetail { + projection_name: self.projection_name.to_string(), + projection_generation: self.projection_generation.to_string(), + checkpoint_watermark: self.checkpoint_watermark, + view_applied_through: self.view_applied_through, + source_high_watermark: self.source_high_watermark, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProjectionCheckpointDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.projection_name) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.checkpoint_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.view_applied_through) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.source_high_watermark) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_name, buf); + ::buffa::types::put_string_field(2u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(3u32, self.checkpoint_watermark, buf); + ::buffa::types::put_uint64_field(4u32, self.view_applied_through, buf); + ::buffa::types::put_uint64_field(5u32, self.source_high_watermark, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProjectionCheckpointDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("projectionName", self.projection_name)?; + } + { + __map.serialize_entry("projectionGeneration", self.projection_generation)?; + } + { + __map + .serialize_entry( + "checkpointWatermark", + &::buffa::json_helpers::ProtoJson(&self.checkpoint_watermark), + )?; + } + { + __map + .serialize_entry( + "viewAppliedThrough", + &::buffa::json_helpers::ProtoJson(&self.view_applied_through), + )?; + } + { + __map + .serialize_entry( + "sourceHighWatermark", + &::buffa::json_helpers::ProtoJson(&self.source_high_watermark), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProjectionCheckpointDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ProjectionCheckpointDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail"; +} +::buffa::impl_default_view_instance!(ProjectionCheckpointDetailView); +::buffa::impl_view_reborrow!(ProjectionCheckpointDetailView); +/** Self-contained, `'static` owned view of a `ProjectionCheckpointDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProjectionCheckpointDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProjectionCheckpointDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProjectionCheckpointDetailOwnedView( + ::buffa::OwnedView>, +); +impl ProjectionCheckpointDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionCheckpointDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionCheckpointDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProjectionCheckpointDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionCheckpointDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProjectionCheckpointDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProjectionCheckpointDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProjectionCheckpointDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `projection_name` + #[must_use] + pub fn projection_name(&self) -> &'_ str { + self.0.reborrow().projection_name + } + /// Field 2: `projection_generation` + #[must_use] + pub fn projection_generation(&self) -> &'_ str { + self.0.reborrow().projection_generation + } + /// What the checkpoint claims was applied. + /// + /// Field 3: `checkpoint_watermark` + #[must_use] + pub fn checkpoint_watermark(&self) -> u64 { + self.0.reborrow().checkpoint_watermark + } + /// What the materialized view actually reflects. Below the checkpoint means + /// the checkpoint is lying about work the view never received. + /// + /// Field 4: `view_applied_through` + #[must_use] + pub fn view_applied_through(&self) -> u64 { + self.0.reborrow().view_applied_through + } + /// The source head. Below the checkpoint means the checkpoint refers to + /// history this stream does not have. + /// + /// Field 5: `source_high_watermark` + #[must_use] + pub fn source_high_watermark(&self) -> u64 { + self.0.reborrow().source_high_watermark + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProjectionCheckpointDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ProjectionCheckpointDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProjectionCheckpointDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProjectionCheckpointDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProjectionCheckpointDetail { + type View<'a> = ProjectionCheckpointDetailView<'a>; + type ViewHandle = ProjectionCheckpointDetailOwnedView; +} +impl ::serde::Serialize for ProjectionCheckpointDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ArtifactDigestDetail distinguishes the three ways an artifact fails +/// verification, which the digests alone cannot express. +#[derive(Clone, Debug, Default)] +pub struct ArtifactDigestDetailView<'a> { + /// Field 1: `artifact_id` + pub artifact_id: &'a str, + /// Field 2: `observation` + pub observation: ::buffa::EnumValue, + /// The digest recorded when the artifact was stored. + /// + /// Field 3: `expected_digest` + pub expected_digest: &'a str, + /// The digest computed during this check. Unset when the content could not be + /// read at all, which is why this is not simply compared to the expected one. + /// + /// Field 4: `observed_digest` + pub observed_digest: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ArtifactDigestDetailView<'a> { + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `observation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observation(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `expected_digest` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_expected_digest(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ArtifactDigestDetailView<'a> { + type Owned = super::super::ArtifactDigestDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.observation = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.expected_digest = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.observed_digest = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ArtifactDigestDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ArtifactDigestDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ArtifactDigestDetail { + artifact_id: self.artifact_id.to_string(), + observation: self.observation, + expected_digest: self.expected_digest.to_string(), + observed_digest: self.observed_digest.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ArtifactDigestDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.observation.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.expected_digest) as u64; + if let Some(ref v) = self.observed_digest { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.observation.to_i32(), buf); + ::buffa::types::put_string_field(3u32, &self.expected_digest, buf); + if let Some(ref v) = self.observed_digest { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ArtifactDigestDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + { + __map.serialize_entry("observation", &self.observation)?; + } + { + __map.serialize_entry("expectedDigest", self.expected_digest)?; + } + if let ::core::option::Option::Some(__v) = self.observed_digest { + __map.serialize_entry("observedDigest", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ArtifactDigestDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ArtifactDigestDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail"; +} +::buffa::impl_default_view_instance!(ArtifactDigestDetailView); +::buffa::impl_view_reborrow!(ArtifactDigestDetailView); +/** Self-contained, `'static` owned view of a `ArtifactDigestDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`ArtifactDigestDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ArtifactDigestDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ArtifactDigestDetailOwnedView( + ::buffa::OwnedView>, +); +impl ArtifactDigestDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactDigestDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactDigestDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ArtifactDigestDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactDigestDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ArtifactDigestDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ArtifactDigestDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ArtifactDigestDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// Field 2: `observation` + #[must_use] + pub fn observation( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().observation + } + /// The digest recorded when the artifact was stored. + /// + /// Field 3: `expected_digest` + #[must_use] + pub fn expected_digest(&self) -> &'_ str { + self.0.reborrow().expected_digest + } + /// The digest computed during this check. Unset when the content could not be + /// read at all, which is why this is not simply compared to the expected one. + /// + /// Field 4: `observed_digest` + #[must_use] + pub fn observed_digest(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().observed_digest + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ArtifactDigestDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ArtifactDigestDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ArtifactDigestDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ArtifactDigestDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ArtifactDigestDetail { + type View<'a> = ArtifactDigestDetailView<'a>; + type ViewHandle = ArtifactDigestDetailOwnedView; +} +impl ::serde::Serialize for ArtifactDigestDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// OperationLedgerDetail describes a side effect that never settled. +#[derive(Clone, Debug, Default)] +pub struct OperationLedgerDetailView<'a> { + /// Field 1: `operation_id` + pub operation_id: &'a str, + /// Field 2: `reserved_at` + pub reserved_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// How far past its expected settlement window the operation is. Unset when no + /// window applies. + /// + /// Field 3: `overdue_by` + pub overdue_by: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// True when an indeterminate outcome was recorded, meaning the side effect + /// may or may not have run. An operator must not assume either. + /// + /// Field 4: `outcome_indeterminate` + pub outcome_indeterminate: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> OperationLedgerDetailView<'a> { + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reserved_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reserved_at(&self) -> bool { + self.reserved_at.is_set() + } + /**Whether required field `outcome_indeterminate` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome_indeterminate(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for OperationLedgerDetailView<'a> { + type Owned = super::super::OperationLedgerDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.reserved_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.reserved_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.overdue_by.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.overdue_by = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome_indeterminate = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::OperationLedgerDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::OperationLedgerDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::OperationLedgerDetail { + operation_id: self.operation_id.to_string(), + reserved_at: match self.reserved_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + overdue_by: match self.overdue_by.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + outcome_indeterminate: self.outcome_indeterminate, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for OperationLedgerDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.reserved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.reserved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.overdue_by.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.overdue_by.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + if self.reserved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.reserved_at.write_to(__cache, buf); + } + if self.overdue_by.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.overdue_by.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(4u32, self.outcome_indeterminate, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for OperationLedgerDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.reserved_at.as_option() { + __map.serialize_entry("reservedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.overdue_by.as_option() { + __map.serialize_entry("overdueBy", __v)?; + } + } + { + __map.serialize_entry("outcomeIndeterminate", &self.outcome_indeterminate)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for OperationLedgerDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OperationLedgerDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail"; +} +::buffa::impl_default_view_instance!(OperationLedgerDetailView); +::buffa::impl_view_reborrow!(OperationLedgerDetailView); +/** Self-contained, `'static` owned view of a `OperationLedgerDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`OperationLedgerDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OperationLedgerDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct OperationLedgerDetailOwnedView( + ::buffa::OwnedView>, +); +impl OperationLedgerDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationLedgerDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationLedgerDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::OperationLedgerDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationLedgerDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`OperationLedgerDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &OperationLedgerDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::OperationLedgerDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 2: `reserved_at` + #[must_use] + pub fn reserved_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().reserved_at + } + /// How far past its expected settlement window the operation is. Unset when no + /// window applies. + /// + /// Field 3: `overdue_by` + #[must_use] + pub fn overdue_by( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().overdue_by + } + /// True when an indeterminate outcome was recorded, meaning the side effect + /// may or may not have run. An operator must not assume either. + /// + /// Field 4: `outcome_indeterminate` + #[must_use] + pub fn outcome_indeterminate(&self) -> bool { + self.0.reborrow().outcome_indeterminate + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for OperationLedgerDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + OperationLedgerDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: OperationLedgerDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for OperationLedgerDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::OperationLedgerDetail { + type View<'a> = OperationLedgerDetailView<'a>; + type ViewHandle = OperationLedgerDetailOwnedView; +} +impl ::serde::Serialize for OperationLedgerDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// UnreconciledWorkDetail describes work the fold shows as started and never +/// finished. +#[derive(Clone, Debug, Default)] +pub struct UnreconciledWorkDetailView<'a> { + /// Tool execution id, delegation id, or saga id, per the subject kind. + /// + /// Field 1: `entity_id` + pub entity_id: &'a str, + /// Field 2: `started_at` + pub started_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// True when the session has already reached a terminal marker. A session can + /// be terminally successful and still have work stranded in flight, and that + /// combination is exactly what a reader treating terminal as complete will + /// miss. + /// + /// Field 3: `session_terminal` + pub session_terminal: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UnreconciledWorkDetailView<'a> { + /**Whether required field `entity_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_entity_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `started_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_started_at(&self) -> bool { + self.started_at.is_set() + } + /**Whether required field `session_terminal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_terminal(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UnreconciledWorkDetailView<'a> { + type Owned = super::super::UnreconciledWorkDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.entity_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.started_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.started_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.session_terminal = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::UnreconciledWorkDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::UnreconciledWorkDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UnreconciledWorkDetail { + entity_id: self.entity_id.to_string(), + started_at: match self.started_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + session_terminal: self.session_terminal, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UnreconciledWorkDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.entity_id) as u64; + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.entity_id, buf); + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.session_terminal, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UnreconciledWorkDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("entityId", self.entity_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.started_at.as_option() { + __map.serialize_entry("startedAt", __v)?; + } + } + { + __map.serialize_entry("sessionTerminal", &self.session_terminal)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UnreconciledWorkDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "UnreconciledWorkDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail"; +} +::buffa::impl_default_view_instance!(UnreconciledWorkDetailView); +::buffa::impl_view_reborrow!(UnreconciledWorkDetailView); +/** Self-contained, `'static` owned view of a `UnreconciledWorkDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`UnreconciledWorkDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UnreconciledWorkDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UnreconciledWorkDetailOwnedView( + ::buffa::OwnedView>, +); +impl UnreconciledWorkDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnreconciledWorkDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnreconciledWorkDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UnreconciledWorkDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnreconciledWorkDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`UnreconciledWorkDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UnreconciledWorkDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UnreconciledWorkDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Tool execution id, delegation id, or saga id, per the subject kind. + /// + /// Field 1: `entity_id` + #[must_use] + pub fn entity_id(&self) -> &'_ str { + self.0.reborrow().entity_id + } + /// Field 2: `started_at` + #[must_use] + pub fn started_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().started_at + } + /// True when the session has already reached a terminal marker. A session can + /// be terminally successful and still have work stranded in flight, and that + /// combination is exactly what a reader treating terminal as complete will + /// miss. + /// + /// Field 3: `session_terminal` + #[must_use] + pub fn session_terminal(&self) -> bool { + self.0.reborrow().session_terminal + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for UnreconciledWorkDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + UnreconciledWorkDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UnreconciledWorkDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for UnreconciledWorkDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UnreconciledWorkDetail { + type View<'a> = UnreconciledWorkDetailView<'a>; + type ViewHandle = UnreconciledWorkDetailOwnedView; +} +impl ::serde::Serialize for UnreconciledWorkDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view_oneof.rs new file mode 100644 index 0000000000..2bf85bcfca --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.__view_oneof.rs @@ -0,0 +1,42 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/finding.proto + +pub mod finding { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Detail<'a> { + EventDecode( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::EventDecodeDetailView<'a>, + >, + ), + ProjectionCheckpoint( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::ProjectionCheckpointDetailView< + 'a, + >, + >, + ), + ArtifactDigest( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::ArtifactDigestDetailView<'a>, + >, + ), + OperationLedger( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OperationLedgerDetailView<'a>, + >, + ), + UnreconciledWork( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::UnreconciledWorkDetailView<'a>, + >, + ), + Orphan( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OrphanDetailView<'a>, + >, + ), + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.rs new file mode 100644 index 0000000000..29c131ceb3 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.finding.rs @@ -0,0 +1,3049 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/finding.proto + +/// FindingSeverity is what an operator has to decide, not a feelings scale. +/// +/// The question a severity answers here is whether rebuilding derived state can +/// fix this. That is the only distinction that changes what an operator does +/// next, so it is the one the enum encodes. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum FindingSeverity { + FINDING_SEVERITY_UNSPECIFIED = 0i32, + /// Worth knowing, nothing is wrong. A projection a few events behind a busy + /// stream is the normal state of a projection, not a defect. + FINDING_SEVERITY_INFO = 1i32, + /// Derived state disagrees with the stream. Reads may be wrong, the stream is + /// intact, and rebuilding from it is expected to resolve the finding. + FINDING_SEVERITY_DEGRADED = 2i32, + /// The stream itself cannot be fully interpreted. No amount of rebuilding + /// helps, because the thing that would be rebuilt from is the problem. These + /// findings usually carry no available repairs, and that is the honest answer + /// rather than a gap. + FINDING_SEVERITY_CORRUPT = 3i32, +} +impl FindingSeverity { + ///Idiomatic alias for [`Self::FINDING_SEVERITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::FINDING_SEVERITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::FINDING_SEVERITY_INFO`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Info: Self = Self::FINDING_SEVERITY_INFO; + ///Idiomatic alias for [`Self::FINDING_SEVERITY_DEGRADED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Degraded: Self = Self::FINDING_SEVERITY_DEGRADED; + ///Idiomatic alias for [`Self::FINDING_SEVERITY_CORRUPT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Corrupt: Self = Self::FINDING_SEVERITY_CORRUPT; +} +impl ::core::default::Default for FindingSeverity { + fn default() -> Self { + Self::FINDING_SEVERITY_UNSPECIFIED + } +} +impl ::serde::Serialize for FindingSeverity { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for FindingSeverity { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = FindingSeverity; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(FindingSeverity) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for FindingSeverity { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for FindingSeverity { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::FINDING_SEVERITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::FINDING_SEVERITY_INFO), + 2i32 => ::core::option::Option::Some(Self::FINDING_SEVERITY_DEGRADED), + 3i32 => ::core::option::Option::Some(Self::FINDING_SEVERITY_CORRUPT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::FINDING_SEVERITY_UNSPECIFIED => "FINDING_SEVERITY_UNSPECIFIED", + Self::FINDING_SEVERITY_INFO => "FINDING_SEVERITY_INFO", + Self::FINDING_SEVERITY_DEGRADED => "FINDING_SEVERITY_DEGRADED", + Self::FINDING_SEVERITY_CORRUPT => "FINDING_SEVERITY_CORRUPT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "FINDING_SEVERITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::FINDING_SEVERITY_UNSPECIFIED) + } + "FINDING_SEVERITY_INFO" => { + ::core::option::Option::Some(Self::FINDING_SEVERITY_INFO) + } + "FINDING_SEVERITY_DEGRADED" => { + ::core::option::Option::Some(Self::FINDING_SEVERITY_DEGRADED) + } + "FINDING_SEVERITY_CORRUPT" => { + ::core::option::Option::Some(Self::FINDING_SEVERITY_CORRUPT) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::FINDING_SEVERITY_UNSPECIFIED, + Self::FINDING_SEVERITY_INFO, + Self::FINDING_SEVERITY_DEGRADED, + Self::FINDING_SEVERITY_CORRUPT, + ] + } +} +/// FindingKind is what was observed. +/// +/// Open by protobuf's rules and treated as open here: a reader that meets an +/// unrecognized kind has reached a newer doctor and must surface it as an +/// unknown finding rather than drop it. A dropped finding reads as health. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum FindingKind { + FINDING_KIND_UNSPECIFIED = 0i32, + /// The session's stream does not exist. + FINDING_KIND_STREAM_MISSING = 1i32, + /// A creation batch landed partially. The session exists but its opening + /// invariants were never completed. + FINDING_KIND_CREATION_BATCH_INCOMPLETE = 2i32, + /// An event at a known ordinal could not be decoded. + FINDING_KIND_EVENT_DECODE_FAILED = 3i32, + /// An event carries a type this build does not know. Distinct from a decode + /// failure: the bytes may be fine and this reader is simply older. + FINDING_KIND_UNSUPPORTED_EVENT_TYPE = 4i32, + /// Folding the stream did not produce a state. Usually downstream of a decode + /// failure, reported separately because a replay can also fail on events that + /// each decode cleanly. + FINDING_KIND_AGGREGATE_REPLAY_FAILED = 5i32, + /// A snapshot does not match a replay of the events it claims to cover. + FINDING_KIND_SNAPSHOT_INVALID = 6i32, + /// A snapshot is valid but far enough behind to have stopped being useful. + FINDING_KIND_SNAPSHOT_BEHIND = 7i32, + /// A projection is behind its source beyond the configured tolerance. + FINDING_KIND_PROJECTION_BEHIND = 8i32, + /// A projection failed its own validity checks. + FINDING_KIND_PROJECTION_INVALID = 9i32, + /// A projection checkpoint claims a position the source stream does not have. + /// Nothing legitimate produces this; it means the checkpoint and the stream + /// come from different histories. + FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE = 10i32, + /// A projection checkpoint claims to have applied an event that is absent from + /// the materialized view. The checkpoint and the view disagree about the same + /// projection. + FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT = 11i32, + /// An artifact referenced by the session is not present in storage. + FINDING_KIND_ARTIFACT_MISSING = 12i32, + /// An artifact is present and its content no longer matches its recorded + /// digest. + FINDING_KIND_ARTIFACT_DIGEST_MISMATCH = 13i32, + /// An artifact claim or multipart upload references nothing durable. + FINDING_KIND_ORPHANED_ARTIFACT_CLAIM = 14i32, + /// A recovery checkpoint or its attestation failed verification. + FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID = 15i32, + /// A delegation, detach, or cascade sequence started and never reached a + /// terminal step. + FINDING_KIND_SAGA_INCOMPLETE = 16i32, + /// A reserved operation recorded an indeterminate outcome. Non-terminal by + /// design, so this is a finding only once it is also overdue. + FINDING_KIND_OPERATION_OUTCOME_UNKNOWN = 17i32, + /// A reserved operation has recorded no outcome past its expected settlement + /// window. + FINDING_KIND_OPERATION_OUTCOME_OVERDUE = 18i32, + /// A tool call reached a started state and never recorded a terminal outcome, + /// in a session that is already terminal. This is the crash-recovery case the + /// aggregate's fold exists to expose. + FINDING_KIND_TOOL_CALL_UNRECONCILED = 19i32, + /// A retention or cold-tier watermark disagrees with what is actually + /// retained. + FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT = 20i32, + /// Derived state left behind by a computation that no longer runs: an + /// abandoned projection generation, staging from a finished migration, a + /// reconciliation lease whose holder never came back. + /// + /// Separate from ORPHANED_ARTIFACT_CLAIM because releasing it destroys + /// something the stream can regenerate, and that difference is the whole basis + /// on which an operator decides how carefully to look first. + FINDING_KIND_ORPHANED_DERIVED_STATE = 21i32, +} +impl FindingKind { + ///Idiomatic alias for [`Self::FINDING_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::FINDING_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::FINDING_KIND_STREAM_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const StreamMissing: Self = Self::FINDING_KIND_STREAM_MISSING; + ///Idiomatic alias for [`Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CreationBatchIncomplete: Self = Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE; + ///Idiomatic alias for [`Self::FINDING_KIND_EVENT_DECODE_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const EventDecodeFailed: Self = Self::FINDING_KIND_EVENT_DECODE_FAILED; + ///Idiomatic alias for [`Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnsupportedEventType: Self = Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE; + ///Idiomatic alias for [`Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AggregateReplayFailed: Self = Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED; + ///Idiomatic alias for [`Self::FINDING_KIND_SNAPSHOT_INVALID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SnapshotInvalid: Self = Self::FINDING_KIND_SNAPSHOT_INVALID; + ///Idiomatic alias for [`Self::FINDING_KIND_SNAPSHOT_BEHIND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SnapshotBehind: Self = Self::FINDING_KIND_SNAPSHOT_BEHIND; + ///Idiomatic alias for [`Self::FINDING_KIND_PROJECTION_BEHIND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionBehind: Self = Self::FINDING_KIND_PROJECTION_BEHIND; + ///Idiomatic alias for [`Self::FINDING_KIND_PROJECTION_INVALID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionInvalid: Self = Self::FINDING_KIND_PROJECTION_INVALID; + ///Idiomatic alias for [`Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionCheckpointAheadOfSource: Self = Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE; + ///Idiomatic alias for [`Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionCheckpointInconsistent: Self = Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT; + ///Idiomatic alias for [`Self::FINDING_KIND_ARTIFACT_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ArtifactMissing: Self = Self::FINDING_KIND_ARTIFACT_MISSING; + ///Idiomatic alias for [`Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ArtifactDigestMismatch: Self = Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH; + ///Idiomatic alias for [`Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OrphanedArtifactClaim: Self = Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM; + ///Idiomatic alias for [`Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CheckpointAttestationInvalid: Self = Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID; + ///Idiomatic alias for [`Self::FINDING_KIND_SAGA_INCOMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SagaIncomplete: Self = Self::FINDING_KIND_SAGA_INCOMPLETE; + ///Idiomatic alias for [`Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationOutcomeUnknown: Self = Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN; + ///Idiomatic alias for [`Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationOutcomeOverdue: Self = Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE; + ///Idiomatic alias for [`Self::FINDING_KIND_TOOL_CALL_UNRECONCILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ToolCallUnreconciled: Self = Self::FINDING_KIND_TOOL_CALL_UNRECONCILED; + ///Idiomatic alias for [`Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RetentionWatermarkInconsistent: Self = Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT; + ///Idiomatic alias for [`Self::FINDING_KIND_ORPHANED_DERIVED_STATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OrphanedDerivedState: Self = Self::FINDING_KIND_ORPHANED_DERIVED_STATE; +} +impl ::core::default::Default for FindingKind { + fn default() -> Self { + Self::FINDING_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for FindingKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for FindingKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = FindingKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(FindingKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for FindingKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for FindingKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::FINDING_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::FINDING_KIND_STREAM_MISSING), + 2i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE, + ) + } + 3i32 => ::core::option::Option::Some(Self::FINDING_KIND_EVENT_DECODE_FAILED), + 4i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE) + } + 5i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED) + } + 6i32 => ::core::option::Option::Some(Self::FINDING_KIND_SNAPSHOT_INVALID), + 7i32 => ::core::option::Option::Some(Self::FINDING_KIND_SNAPSHOT_BEHIND), + 8i32 => ::core::option::Option::Some(Self::FINDING_KIND_PROJECTION_BEHIND), + 9i32 => ::core::option::Option::Some(Self::FINDING_KIND_PROJECTION_INVALID), + 10i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE, + ) + } + 11i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT, + ) + } + 12i32 => ::core::option::Option::Some(Self::FINDING_KIND_ARTIFACT_MISSING), + 13i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH) + } + 14i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM) + } + 15i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID, + ) + } + 16i32 => ::core::option::Option::Some(Self::FINDING_KIND_SAGA_INCOMPLETE), + 17i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN, + ) + } + 18i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE, + ) + } + 19i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_TOOL_CALL_UNRECONCILED) + } + 20i32 => { + ::core::option::Option::Some( + Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT, + ) + } + 21i32 => { + ::core::option::Option::Some(Self::FINDING_KIND_ORPHANED_DERIVED_STATE) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::FINDING_KIND_UNSPECIFIED => "FINDING_KIND_UNSPECIFIED", + Self::FINDING_KIND_STREAM_MISSING => "FINDING_KIND_STREAM_MISSING", + Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE => { + "FINDING_KIND_CREATION_BATCH_INCOMPLETE" + } + Self::FINDING_KIND_EVENT_DECODE_FAILED => "FINDING_KIND_EVENT_DECODE_FAILED", + Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE => { + "FINDING_KIND_UNSUPPORTED_EVENT_TYPE" + } + Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED => { + "FINDING_KIND_AGGREGATE_REPLAY_FAILED" + } + Self::FINDING_KIND_SNAPSHOT_INVALID => "FINDING_KIND_SNAPSHOT_INVALID", + Self::FINDING_KIND_SNAPSHOT_BEHIND => "FINDING_KIND_SNAPSHOT_BEHIND", + Self::FINDING_KIND_PROJECTION_BEHIND => "FINDING_KIND_PROJECTION_BEHIND", + Self::FINDING_KIND_PROJECTION_INVALID => "FINDING_KIND_PROJECTION_INVALID", + Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE => { + "FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE" + } + Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT => { + "FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT" + } + Self::FINDING_KIND_ARTIFACT_MISSING => "FINDING_KIND_ARTIFACT_MISSING", + Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH => { + "FINDING_KIND_ARTIFACT_DIGEST_MISMATCH" + } + Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM => { + "FINDING_KIND_ORPHANED_ARTIFACT_CLAIM" + } + Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID => { + "FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID" + } + Self::FINDING_KIND_SAGA_INCOMPLETE => "FINDING_KIND_SAGA_INCOMPLETE", + Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN => { + "FINDING_KIND_OPERATION_OUTCOME_UNKNOWN" + } + Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE => { + "FINDING_KIND_OPERATION_OUTCOME_OVERDUE" + } + Self::FINDING_KIND_TOOL_CALL_UNRECONCILED => { + "FINDING_KIND_TOOL_CALL_UNRECONCILED" + } + Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT => { + "FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT" + } + Self::FINDING_KIND_ORPHANED_DERIVED_STATE => { + "FINDING_KIND_ORPHANED_DERIVED_STATE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "FINDING_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::FINDING_KIND_UNSPECIFIED) + } + "FINDING_KIND_STREAM_MISSING" => { + ::core::option::Option::Some(Self::FINDING_KIND_STREAM_MISSING) + } + "FINDING_KIND_CREATION_BATCH_INCOMPLETE" => { + ::core::option::Option::Some( + Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE, + ) + } + "FINDING_KIND_EVENT_DECODE_FAILED" => { + ::core::option::Option::Some(Self::FINDING_KIND_EVENT_DECODE_FAILED) + } + "FINDING_KIND_UNSUPPORTED_EVENT_TYPE" => { + ::core::option::Option::Some(Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE) + } + "FINDING_KIND_AGGREGATE_REPLAY_FAILED" => { + ::core::option::Option::Some(Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED) + } + "FINDING_KIND_SNAPSHOT_INVALID" => { + ::core::option::Option::Some(Self::FINDING_KIND_SNAPSHOT_INVALID) + } + "FINDING_KIND_SNAPSHOT_BEHIND" => { + ::core::option::Option::Some(Self::FINDING_KIND_SNAPSHOT_BEHIND) + } + "FINDING_KIND_PROJECTION_BEHIND" => { + ::core::option::Option::Some(Self::FINDING_KIND_PROJECTION_BEHIND) + } + "FINDING_KIND_PROJECTION_INVALID" => { + ::core::option::Option::Some(Self::FINDING_KIND_PROJECTION_INVALID) + } + "FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE" => { + ::core::option::Option::Some( + Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE, + ) + } + "FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT" => { + ::core::option::Option::Some( + Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT, + ) + } + "FINDING_KIND_ARTIFACT_MISSING" => { + ::core::option::Option::Some(Self::FINDING_KIND_ARTIFACT_MISSING) + } + "FINDING_KIND_ARTIFACT_DIGEST_MISMATCH" => { + ::core::option::Option::Some(Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH) + } + "FINDING_KIND_ORPHANED_ARTIFACT_CLAIM" => { + ::core::option::Option::Some(Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM) + } + "FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID" => { + ::core::option::Option::Some( + Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID, + ) + } + "FINDING_KIND_SAGA_INCOMPLETE" => { + ::core::option::Option::Some(Self::FINDING_KIND_SAGA_INCOMPLETE) + } + "FINDING_KIND_OPERATION_OUTCOME_UNKNOWN" => { + ::core::option::Option::Some( + Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN, + ) + } + "FINDING_KIND_OPERATION_OUTCOME_OVERDUE" => { + ::core::option::Option::Some( + Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE, + ) + } + "FINDING_KIND_TOOL_CALL_UNRECONCILED" => { + ::core::option::Option::Some(Self::FINDING_KIND_TOOL_CALL_UNRECONCILED) + } + "FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT" => { + ::core::option::Option::Some( + Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT, + ) + } + "FINDING_KIND_ORPHANED_DERIVED_STATE" => { + ::core::option::Option::Some(Self::FINDING_KIND_ORPHANED_DERIVED_STATE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::FINDING_KIND_UNSPECIFIED, + Self::FINDING_KIND_STREAM_MISSING, + Self::FINDING_KIND_CREATION_BATCH_INCOMPLETE, + Self::FINDING_KIND_EVENT_DECODE_FAILED, + Self::FINDING_KIND_UNSUPPORTED_EVENT_TYPE, + Self::FINDING_KIND_AGGREGATE_REPLAY_FAILED, + Self::FINDING_KIND_SNAPSHOT_INVALID, + Self::FINDING_KIND_SNAPSHOT_BEHIND, + Self::FINDING_KIND_PROJECTION_BEHIND, + Self::FINDING_KIND_PROJECTION_INVALID, + Self::FINDING_KIND_PROJECTION_CHECKPOINT_AHEAD_OF_SOURCE, + Self::FINDING_KIND_PROJECTION_CHECKPOINT_INCONSISTENT, + Self::FINDING_KIND_ARTIFACT_MISSING, + Self::FINDING_KIND_ARTIFACT_DIGEST_MISMATCH, + Self::FINDING_KIND_ORPHANED_ARTIFACT_CLAIM, + Self::FINDING_KIND_CHECKPOINT_ATTESTATION_INVALID, + Self::FINDING_KIND_SAGA_INCOMPLETE, + Self::FINDING_KIND_OPERATION_OUTCOME_UNKNOWN, + Self::FINDING_KIND_OPERATION_OUTCOME_OVERDUE, + Self::FINDING_KIND_TOOL_CALL_UNRECONCILED, + Self::FINDING_KIND_RETENTION_WATERMARK_INCONSISTENT, + Self::FINDING_KIND_ORPHANED_DERIVED_STATE, + ] + } +} +/// SubjectKind is which part of a session a finding concerns. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SubjectKind { + SUBJECT_KIND_UNSPECIFIED = 0i32, + SUBJECT_KIND_STREAM = 1i32, + SUBJECT_KIND_EVENT = 2i32, + SUBJECT_KIND_SNAPSHOT = 3i32, + SUBJECT_KIND_PROJECTION = 4i32, + SUBJECT_KIND_ARTIFACT = 5i32, + SUBJECT_KIND_OPERATION = 6i32, + SUBJECT_KIND_TOOL_CALL = 7i32, + SUBJECT_KIND_DELEGATION = 8i32, + SUBJECT_KIND_CHECKPOINT = 9i32, +} +impl SubjectKind { + ///Idiomatic alias for [`Self::SUBJECT_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SUBJECT_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::SUBJECT_KIND_STREAM`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Stream: Self = Self::SUBJECT_KIND_STREAM; + ///Idiomatic alias for [`Self::SUBJECT_KIND_EVENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Event: Self = Self::SUBJECT_KIND_EVENT; + ///Idiomatic alias for [`Self::SUBJECT_KIND_SNAPSHOT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Snapshot: Self = Self::SUBJECT_KIND_SNAPSHOT; + ///Idiomatic alias for [`Self::SUBJECT_KIND_PROJECTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Projection: Self = Self::SUBJECT_KIND_PROJECTION; + ///Idiomatic alias for [`Self::SUBJECT_KIND_ARTIFACT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Artifact: Self = Self::SUBJECT_KIND_ARTIFACT; + ///Idiomatic alias for [`Self::SUBJECT_KIND_OPERATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Operation: Self = Self::SUBJECT_KIND_OPERATION; + ///Idiomatic alias for [`Self::SUBJECT_KIND_TOOL_CALL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ToolCall: Self = Self::SUBJECT_KIND_TOOL_CALL; + ///Idiomatic alias for [`Self::SUBJECT_KIND_DELEGATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Delegation: Self = Self::SUBJECT_KIND_DELEGATION; + ///Idiomatic alias for [`Self::SUBJECT_KIND_CHECKPOINT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Checkpoint: Self = Self::SUBJECT_KIND_CHECKPOINT; +} +impl ::core::default::Default for SubjectKind { + fn default() -> Self { + Self::SUBJECT_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for SubjectKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SubjectKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SubjectKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(SubjectKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubjectKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SubjectKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_STREAM), + 2i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_EVENT), + 3i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_SNAPSHOT), + 4i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_PROJECTION), + 5i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_ARTIFACT), + 6i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_OPERATION), + 7i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_TOOL_CALL), + 8i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_DELEGATION), + 9i32 => ::core::option::Option::Some(Self::SUBJECT_KIND_CHECKPOINT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SUBJECT_KIND_UNSPECIFIED => "SUBJECT_KIND_UNSPECIFIED", + Self::SUBJECT_KIND_STREAM => "SUBJECT_KIND_STREAM", + Self::SUBJECT_KIND_EVENT => "SUBJECT_KIND_EVENT", + Self::SUBJECT_KIND_SNAPSHOT => "SUBJECT_KIND_SNAPSHOT", + Self::SUBJECT_KIND_PROJECTION => "SUBJECT_KIND_PROJECTION", + Self::SUBJECT_KIND_ARTIFACT => "SUBJECT_KIND_ARTIFACT", + Self::SUBJECT_KIND_OPERATION => "SUBJECT_KIND_OPERATION", + Self::SUBJECT_KIND_TOOL_CALL => "SUBJECT_KIND_TOOL_CALL", + Self::SUBJECT_KIND_DELEGATION => "SUBJECT_KIND_DELEGATION", + Self::SUBJECT_KIND_CHECKPOINT => "SUBJECT_KIND_CHECKPOINT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SUBJECT_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_UNSPECIFIED) + } + "SUBJECT_KIND_STREAM" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_STREAM) + } + "SUBJECT_KIND_EVENT" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_EVENT) + } + "SUBJECT_KIND_SNAPSHOT" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_SNAPSHOT) + } + "SUBJECT_KIND_PROJECTION" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_PROJECTION) + } + "SUBJECT_KIND_ARTIFACT" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_ARTIFACT) + } + "SUBJECT_KIND_OPERATION" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_OPERATION) + } + "SUBJECT_KIND_TOOL_CALL" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_TOOL_CALL) + } + "SUBJECT_KIND_DELEGATION" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_DELEGATION) + } + "SUBJECT_KIND_CHECKPOINT" => { + ::core::option::Option::Some(Self::SUBJECT_KIND_CHECKPOINT) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SUBJECT_KIND_UNSPECIFIED, + Self::SUBJECT_KIND_STREAM, + Self::SUBJECT_KIND_EVENT, + Self::SUBJECT_KIND_SNAPSHOT, + Self::SUBJECT_KIND_PROJECTION, + Self::SUBJECT_KIND_ARTIFACT, + Self::SUBJECT_KIND_OPERATION, + Self::SUBJECT_KIND_TOOL_CALL, + Self::SUBJECT_KIND_DELEGATION, + Self::SUBJECT_KIND_CHECKPOINT, + ] + } +} +/// ArtifactDigestObservation is what the verification attempt found. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ArtifactDigestObservation { + ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED = 0i32, + /// Content read, digest computed, digests differ. + ARTIFACT_DIGEST_OBSERVATION_MISMATCH = 1i32, + /// Content is not present in storage. + ARTIFACT_DIGEST_OBSERVATION_ABSENT = 2i32, + /// Content is present and could not be read. Distinct from absent: an + /// unreadable artifact may be a permissions or transport problem rather than + /// data loss, and treating it as loss invites a destructive repair. + ARTIFACT_DIGEST_OBSERVATION_UNREADABLE = 3i32, +} +impl ArtifactDigestObservation { + ///Idiomatic alias for [`Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED; + ///Idiomatic alias for [`Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Mismatch: Self = Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH; + ///Idiomatic alias for [`Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Absent: Self = Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT; + ///Idiomatic alias for [`Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unreadable: Self = Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE; +} +impl ::core::default::Default for ArtifactDigestObservation { + fn default() -> Self { + Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED + } +} +impl ::serde::Serialize for ArtifactDigestObservation { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ArtifactDigestObservation { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ArtifactDigestObservation; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ArtifactDigestObservation) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactDigestObservation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ArtifactDigestObservation { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some( + Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED, + ) + } + 1i32 => { + ::core::option::Option::Some(Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH) + } + 2i32 => { + ::core::option::Option::Some(Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT) + } + 3i32 => { + ::core::option::Option::Some( + Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED => { + "ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED" + } + Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH => { + "ARTIFACT_DIGEST_OBSERVATION_MISMATCH" + } + Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT => { + "ARTIFACT_DIGEST_OBSERVATION_ABSENT" + } + Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE => { + "ARTIFACT_DIGEST_OBSERVATION_UNREADABLE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED" => { + ::core::option::Option::Some( + Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED, + ) + } + "ARTIFACT_DIGEST_OBSERVATION_MISMATCH" => { + ::core::option::Option::Some(Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH) + } + "ARTIFACT_DIGEST_OBSERVATION_ABSENT" => { + ::core::option::Option::Some(Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT) + } + "ARTIFACT_DIGEST_OBSERVATION_UNREADABLE" => { + ::core::option::Option::Some( + Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ARTIFACT_DIGEST_OBSERVATION_UNSPECIFIED, + Self::ARTIFACT_DIGEST_OBSERVATION_MISMATCH, + Self::ARTIFACT_DIGEST_OBSERVATION_ABSENT, + Self::ARTIFACT_DIGEST_OBSERVATION_UNREADABLE, + ] + } +} +/// Finding is one inconsistency the doctor observed. +/// +/// A finding is an observation, never an instruction. It says what disagrees +/// with what, and it names the repairs that could address it, but producing one +/// mutates nothing. That separation is the whole design: diagnosis and repair are +/// different operations with different messages, so a caller cannot reach a +/// mutation by filling in one more field on a read. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct Finding { + /// Stable identity for this problem: a digest over `kind` and `subject`. + /// + /// Deliberately not a digest over the observed values. A projection that falls + /// further behind between diagnosis and repair is still the same finding, and + /// an id that changed with every observed byte would make repairs impossible on + /// a busy session. Staleness is caught by re-verifying the finding at repair + /// time, not by comparing ids. + /// + /// Field 1: `finding_id` + #[serde( + rename = "findingId", + alias = "finding_id", + with = "::buffa::json_helpers::proto_string" + )] + pub finding_id: ::buffa::alloc::string::String, + /// Field 2: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Field 3: `severity` + #[serde(rename = "severity", with = "::buffa::json_helpers::proto_enum")] + pub severity: ::buffa::EnumValue, + /// Field 4: `subject` + #[serde(rename = "subject")] + pub subject: ::buffa::MessageField>, + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 5: `summary` + #[serde(rename = "summary", with = "::buffa::json_helpers::proto_string")] + pub summary: ::buffa::alloc::string::String, + /// Repairs that could address this finding, and the only actions a + /// RepairSessionRequest may name for it. An empty list means nothing the + /// doctor can do will help, which is the normal case for a CORRUPT finding. + /// + /// Field 6: `available_repairs` + #[serde( + rename = "availableRepairs", + alias = "available_repairs", + with = "::buffa::json_helpers::repeated_enum", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec" + )] + pub available_repairs: ::buffa::alloc::vec::Vec<::buffa::EnumValue>, + /// Field 7: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + #[serde(flatten)] + pub detail: ::core::option::Option<__buffa::oneof::finding::Detail>, +} +impl ::core::fmt::Debug for Finding { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Finding") + .field("finding_id", &self.finding_id) + .field("kind", &self.kind) + .field("severity", &self.severity) + .field("subject", &self.subject) + .field("summary", &self.summary) + .field("available_repairs", &self.available_repairs) + .field("observed_at", &self.observed_at) + .field("detail", &self.detail) + .finish() + } +} +impl Finding { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.Finding"; +} +::buffa::impl_default_instance!(Finding); +impl ::buffa::MessageName for Finding { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "Finding"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.Finding"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.Finding"; +} +impl ::buffa::Message for Finding { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.severity.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.subject.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.subject.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary) as u64; + if !self.available_repairs.is_empty() { + let payload: u64 = self + .available_repairs + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + __buffa::oneof::finding::Detail::EventDecode(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::finding::Detail::ProjectionCheckpoint(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::finding::Detail::ArtifactDigest(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::finding::Detail::OperationLedger(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::finding::Detail::UnreconciledWork(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::finding::Detail::Orphan(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + ::buffa::types::put_int32_field(3u32, self.severity.to_i32(), buf); + if self.subject.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.subject.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.summary, buf); + if !self.available_repairs.is_empty() { + let payload: u64 = self + .available_repairs + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(6u32, payload, buf); + for v in &self.available_repairs { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + __buffa::oneof::finding::Detail::EventDecode(x) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::finding::Detail::ProjectionCheckpoint(x) => { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::finding::Detail::ArtifactDigest(x) => { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::finding::Detail::OperationLedger(x) => { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::finding::Detail::UnreconciledWork(x) => { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::finding::Detail::Orphan(x) => { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.finding_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.severity = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.subject.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.summary, buf)?; + } + 6u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = usize::try_from(len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + self.available_repairs.reserve(len); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.available_repairs + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut limited)?, + ), + ); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + self.available_repairs + .push( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } else { + return ::core::result::Result::Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::EventDecode(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::EventDecode( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::ProjectionCheckpoint( + ref mut existing, + ), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::ProjectionCheckpoint( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::ArtifactDigest(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::ArtifactDigest( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::OperationLedger(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::OperationLedger( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::UnreconciledWork(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::UnreconciledWork( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::finding::Detail::Orphan(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::finding::Detail::Orphan( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.finding_id.clear(); + self.kind = ::buffa::EnumValue::from(0); + self.severity = ::buffa::EnumValue::from(0); + self.subject = ::buffa::MessageField::none(); + self.summary.clear(); + self.available_repairs.clear(); + self.observed_at = ::buffa::MessageField::none(); + self.detail = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for Finding { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = Finding; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct Finding") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __f_finding_id: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __f_kind: ::core::option::Option< + ::buffa::EnumValue, + > = None; + let mut __f_severity: ::core::option::Option< + ::buffa::EnumValue, + > = None; + let mut __f_subject: ::core::option::Option< + ::buffa::MessageField>, + > = None; + let mut __f_summary: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __f_available_repairs: ::core::option::Option< + ::buffa::alloc::vec::Vec<::buffa::EnumValue>, + > = None; + let mut __f_observed_at: ::core::option::Option< + ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + > = None; + let mut __oneof_detail: ::core::option::Option< + __buffa::oneof::finding::Detail, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "findingId" | "finding_id" => { + __f_finding_id = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "kind" => { + __f_kind = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::EnumValue; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::EnumValue, + D::Error, + > { + ::buffa::json_helpers::proto_enum::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "severity" => { + __f_severity = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::EnumValue; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::EnumValue, + D::Error, + > { + ::buffa::json_helpers::proto_enum::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "subject" => { + __f_subject = Some( + map + .next_value::< + ::buffa::MessageField< + SubjectRef, + ::buffa::Inline, + >, + >()?, + ); + } + "summary" => { + __f_summary = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "availableRepairs" | "available_repairs" => { + __f_available_repairs = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::vec::Vec< + ::buffa::EnumValue, + >; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::vec::Vec<::buffa::EnumValue>, + D::Error, + > { + ::buffa::json_helpers::repeated_enum::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "observedAt" | "observed_at" => { + __f_observed_at = Some( + map + .next_value::< + ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + >()?, + ); + } + "eventDecode" | "event_decode" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + EventDecodeDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::EventDecode( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "projectionCheckpoint" | "projection_checkpoint" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + ProjectionCheckpointDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::ProjectionCheckpoint( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "artifactDigest" | "artifact_digest" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + ArtifactDigestDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::ArtifactDigest( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "operationLedger" | "operation_ledger" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OperationLedgerDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::OperationLedger( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "unreconciledWork" | "unreconciled_work" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + UnreconciledWorkDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::UnreconciledWork( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "orphan" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OrphanDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::finding::Detail::Orphan( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + if let ::core::option::Option::Some(v) = __f_finding_id { + __r.finding_id = v; + } + if let ::core::option::Option::Some(v) = __f_kind { + __r.kind = v; + } + if let ::core::option::Option::Some(v) = __f_severity { + __r.severity = v; + } + if let ::core::option::Option::Some(v) = __f_subject { + __r.subject = v; + } + if let ::core::option::Option::Some(v) = __f_summary { + __r.summary = v; + } + if let ::core::option::Option::Some(v) = __f_available_repairs { + __r.available_repairs = v; + } + if let ::core::option::Option::Some(v) = __f_observed_at { + __r.observed_at = v; + } + __r.detail = __oneof_detail; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for Finding { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FINDING_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.Finding", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod finding { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::__buffa::oneof::finding::Detail; + #[doc(inline)] + pub use super::__buffa::view::oneof::finding::Detail as DetailView; +} +/// SubjectRef says what a finding is about. +/// +/// `kind` is what gives `entity_id` meaning, and the pair travels together for +/// that reason: an id with no idea what it identifies is not a reference. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubjectRef { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Interpreted according to `kind`: an artifact id, an operation id, a tool + /// execution id, a projection name. Unset when `kind` is STREAM, which needs + /// no further identity than the session. + /// + /// Field 3: `entity_id` + #[serde( + rename = "entityId", + alias = "entity_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub entity_id: ::core::option::Option<::buffa::alloc::string::String>, + /// The SessionOrdinal the finding is anchored at. Unset when the finding is + /// not ordinal-scoped, which is not the same as ordinal zero. + /// + /// Field 4: `ordinal` + #[serde( + rename = "ordinal", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub ordinal: ::core::option::Option, +} +impl ::core::fmt::Debug for SubjectRef { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubjectRef") + .field("session_id", &self.session_id) + .field("kind", &self.kind) + .field("entity_id", &self.entity_id) + .field("ordinal", &self.ordinal) + .finish() + } +} +impl SubjectRef { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.SubjectRef"; +} +impl SubjectRef { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::entity_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_entity_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.entity_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::ordinal`] to `Some(value)`, consuming and returning `self`. + pub fn with_ordinal(mut self, value: u64) -> Self { + self.ordinal = Some(value); + self + } +} +::buffa::impl_default_instance!(SubjectRef); +impl ::buffa::MessageName for SubjectRef { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "SubjectRef"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.SubjectRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.SubjectRef"; +} +impl ::buffa::Message for SubjectRef { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.entity_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.entity_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(v) = self.ordinal { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .entity_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.kind = ::buffa::EnumValue::from(0); + self.entity_id = ::core::option::Option::None; + self.ordinal = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubjectRef { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBJECT_REF_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.SubjectRef", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// EventDecodeDetail is enough to find the offending event without re-running +/// the scan. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct EventDecodeDetail { + /// Field 1: `ordinal` + #[serde(rename = "ordinal", with = "::buffa::json_helpers::uint64")] + pub ordinal: u64, + /// Field 2: `type_url` + #[serde( + rename = "typeUrl", + alias = "type_url", + with = "::buffa::json_helpers::proto_string" + )] + pub type_url: ::buffa::alloc::string::String, + /// Decoder error text. Diagnostic only, never parsed. + /// + /// Field 3: `decoder_error` + #[serde( + rename = "decoderError", + alias = "decoder_error", + with = "::buffa::json_helpers::proto_string" + )] + pub decoder_error: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for EventDecodeDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("EventDecodeDetail") + .field("ordinal", &self.ordinal) + .field("type_url", &self.type_url) + .field("decoder_error", &self.decoder_error) + .finish() + } +} +impl EventDecodeDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail"; +} +::buffa::impl_default_instance!(EventDecodeDetail); +impl ::buffa::MessageName for EventDecodeDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "EventDecodeDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail"; +} +impl ::buffa::Message for EventDecodeDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.type_url) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.decoder_error) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.ordinal, buf); + ::buffa::types::put_string_field(2u32, &self.type_url, buf); + ::buffa::types::put_string_field(3u32, &self.decoder_error, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.type_url, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.decoder_error, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ordinal = 0u64; + self.type_url.clear(); + self.decoder_error.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for EventDecodeDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __EVENT_DECODE_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.EventDecodeDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ProjectionCheckpointDetail carries the three positions whose disagreement is +/// the finding, because a checkpoint inconsistency is unreadable without all +/// three. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProjectionCheckpointDetail { + /// Field 1: `projection_name` + #[serde( + rename = "projectionName", + alias = "projection_name", + with = "::buffa::json_helpers::proto_string" + )] + pub projection_name: ::buffa::alloc::string::String, + /// Field 2: `projection_generation` + #[serde( + rename = "projectionGeneration", + alias = "projection_generation", + with = "::buffa::json_helpers::proto_string" + )] + pub projection_generation: ::buffa::alloc::string::String, + /// What the checkpoint claims was applied. + /// + /// Field 3: `checkpoint_watermark` + #[serde( + rename = "checkpointWatermark", + alias = "checkpoint_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub checkpoint_watermark: u64, + /// What the materialized view actually reflects. Below the checkpoint means + /// the checkpoint is lying about work the view never received. + /// + /// Field 4: `view_applied_through` + #[serde( + rename = "viewAppliedThrough", + alias = "view_applied_through", + with = "::buffa::json_helpers::uint64" + )] + pub view_applied_through: u64, + /// The source head. Below the checkpoint means the checkpoint refers to + /// history this stream does not have. + /// + /// Field 5: `source_high_watermark` + #[serde( + rename = "sourceHighWatermark", + alias = "source_high_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub source_high_watermark: u64, +} +impl ::core::fmt::Debug for ProjectionCheckpointDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProjectionCheckpointDetail") + .field("projection_name", &self.projection_name) + .field("projection_generation", &self.projection_generation) + .field("checkpoint_watermark", &self.checkpoint_watermark) + .field("view_applied_through", &self.view_applied_through) + .field("source_high_watermark", &self.source_high_watermark) + .finish() + } +} +impl ProjectionCheckpointDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail"; +} +::buffa::impl_default_instance!(ProjectionCheckpointDetail); +impl ::buffa::MessageName for ProjectionCheckpointDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ProjectionCheckpointDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail"; +} +impl ::buffa::Message for ProjectionCheckpointDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.projection_name) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.checkpoint_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.view_applied_through) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.source_high_watermark) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_name, buf); + ::buffa::types::put_string_field(2u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(3u32, self.checkpoint_watermark, buf); + ::buffa::types::put_uint64_field(4u32, self.view_applied_through, buf); + ::buffa::types::put_uint64_field(5u32, self.source_high_watermark, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.projection_name, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.projection_generation, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.checkpoint_watermark = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.view_applied_through = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source_high_watermark = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.projection_name.clear(); + self.projection_generation.clear(); + self.checkpoint_watermark = 0u64; + self.view_applied_through = 0u64; + self.source_high_watermark = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProjectionCheckpointDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PROJECTION_CHECKPOINT_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ProjectionCheckpointDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ArtifactDigestDetail distinguishes the three ways an artifact fails +/// verification, which the digests alone cannot express. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ArtifactDigestDetail { + /// Field 1: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// Field 2: `observation` + #[serde(rename = "observation", with = "::buffa::json_helpers::proto_enum")] + pub observation: ::buffa::EnumValue, + /// The digest recorded when the artifact was stored. + /// + /// Field 3: `expected_digest` + #[serde( + rename = "expectedDigest", + alias = "expected_digest", + with = "::buffa::json_helpers::proto_string" + )] + pub expected_digest: ::buffa::alloc::string::String, + /// The digest computed during this check. Unset when the content could not be + /// read at all, which is why this is not simply compared to the expected one. + /// + /// Field 4: `observed_digest` + #[serde( + rename = "observedDigest", + alias = "observed_digest", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub observed_digest: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for ArtifactDigestDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ArtifactDigestDetail") + .field("artifact_id", &self.artifact_id) + .field("observation", &self.observation) + .field("expected_digest", &self.expected_digest) + .field("observed_digest", &self.observed_digest) + .finish() + } +} +impl ArtifactDigestDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail"; +} +impl ArtifactDigestDetail { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::observed_digest`] to `Some(value)`, consuming and returning `self`. + pub fn with_observed_digest( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.observed_digest = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ArtifactDigestDetail); +impl ::buffa::MessageName for ArtifactDigestDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ArtifactDigestDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail"; +} +impl ::buffa::Message for ArtifactDigestDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + { + let val = self.observation.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.expected_digest) as u64; + if let Some(ref v) = self.observed_digest { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.artifact_id, buf); + ::buffa::types::put_int32_field(2u32, self.observation.to_i32(), buf); + ::buffa::types::put_string_field(3u32, &self.expected_digest, buf); + if let Some(ref v) = self.observed_digest { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.observation = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.expected_digest, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .observed_digest + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.artifact_id.clear(); + self.observation = ::buffa::EnumValue::from(0); + self.expected_digest.clear(); + self.observed_digest = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactDigestDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ARTIFACT_DIGEST_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ArtifactDigestDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// OperationLedgerDetail describes a side effect that never settled. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct OperationLedgerDetail { + /// Field 1: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 2: `reserved_at` + #[serde(rename = "reservedAt", alias = "reserved_at")] + pub reserved_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// How far past its expected settlement window the operation is. Unset when no + /// window applies. + /// + /// Field 3: `overdue_by` + #[serde( + rename = "overdueBy", + alias = "overdue_by", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub overdue_by: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// True when an indeterminate outcome was recorded, meaning the side effect + /// may or may not have run. An operator must not assume either. + /// + /// Field 4: `outcome_indeterminate` + #[serde( + rename = "outcomeIndeterminate", + alias = "outcome_indeterminate", + with = "::buffa::json_helpers::proto_bool" + )] + pub outcome_indeterminate: bool, +} +impl ::core::fmt::Debug for OperationLedgerDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OperationLedgerDetail") + .field("operation_id", &self.operation_id) + .field("reserved_at", &self.reserved_at) + .field("overdue_by", &self.overdue_by) + .field("outcome_indeterminate", &self.outcome_indeterminate) + .finish() + } +} +impl OperationLedgerDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail"; +} +::buffa::impl_default_instance!(OperationLedgerDetail); +impl ::buffa::MessageName for OperationLedgerDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OperationLedgerDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail"; +} +impl ::buffa::Message for OperationLedgerDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.reserved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.reserved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.overdue_by.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.overdue_by.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + if self.reserved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.reserved_at.write_to(__cache, buf); + } + if self.overdue_by.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.overdue_by.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(4u32, self.outcome_indeterminate, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.reserved_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.overdue_by.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome_indeterminate = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.operation_id.clear(); + self.reserved_at = ::buffa::MessageField::none(); + self.overdue_by = ::buffa::MessageField::none(); + self.outcome_indeterminate = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for OperationLedgerDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OPERATION_LEDGER_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OperationLedgerDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// UnreconciledWorkDetail describes work the fold shows as started and never +/// finished. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UnreconciledWorkDetail { + /// Tool execution id, delegation id, or saga id, per the subject kind. + /// + /// Field 1: `entity_id` + #[serde( + rename = "entityId", + alias = "entity_id", + with = "::buffa::json_helpers::proto_string" + )] + pub entity_id: ::buffa::alloc::string::String, + /// Field 2: `started_at` + #[serde(rename = "startedAt", alias = "started_at")] + pub started_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// True when the session has already reached a terminal marker. A session can + /// be terminally successful and still have work stranded in flight, and that + /// combination is exactly what a reader treating terminal as complete will + /// miss. + /// + /// Field 3: `session_terminal` + #[serde( + rename = "sessionTerminal", + alias = "session_terminal", + with = "::buffa::json_helpers::proto_bool" + )] + pub session_terminal: bool, +} +impl ::core::fmt::Debug for UnreconciledWorkDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UnreconciledWorkDetail") + .field("entity_id", &self.entity_id) + .field("started_at", &self.started_at) + .field("session_terminal", &self.session_terminal) + .finish() + } +} +impl UnreconciledWorkDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail"; +} +::buffa::impl_default_instance!(UnreconciledWorkDetail); +impl ::buffa::MessageName for UnreconciledWorkDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "UnreconciledWorkDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail"; +} +impl ::buffa::Message for UnreconciledWorkDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.entity_id) as u64; + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.entity_id, buf); + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.session_terminal, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.entity_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.started_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.session_terminal = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.entity_id.clear(); + self.started_at = ::buffa::MessageField::none(); + self.session_terminal = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for UnreconciledWorkDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UNRECONCILED_WORK_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.UnreconciledWorkDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.mod.rs new file mode 100644 index 0000000000..b5910e93be --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.mod.rs @@ -0,0 +1,144 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.doctor.v1alpha1.orphan.rs"); +include!("trogonai.session.sessions.doctor.v1alpha1.repair_action.rs"); +include!("trogonai.session.sessions.doctor.v1alpha1.finding.rs"); +include!("trogonai.session.sessions.doctor.v1alpha1.diagnose_session.rs"); +include!("trogonai.session.sessions.doctor.v1alpha1.doctor_error.rs"); +include!("trogonai.session.sessions.doctor.v1alpha1.repair_session.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.doctor.v1alpha1.orphan.__view.rs"); + include!("trogonai.session.sessions.doctor.v1alpha1.finding.__view.rs"); + include!("trogonai.session.sessions.doctor.v1alpha1.diagnose_session.__view.rs"); + include!("trogonai.session.sessions.doctor.v1alpha1.doctor_error.__view.rs"); + include!("trogonai.session.sessions.doctor.v1alpha1.repair_session.__view.rs"); + pub mod oneof { + #[allow(unused_imports)] + use super::*; + include!( + "trogonai.session.sessions.doctor.v1alpha1.finding.__view_oneof.rs" + ); + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.doctor.v1alpha1.finding.__oneof.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__ORPHAN_DETAIL_JSON_ANY); + reg.register_json_any(super::__OWNERSHIP_TRACE_JSON_ANY); + reg.register_json_any(super::__RELEASE_GATE_JSON_ANY); + reg.register_json_any(super::__FINDING_JSON_ANY); + reg.register_json_any(super::__SUBJECT_REF_JSON_ANY); + reg.register_json_any(super::__EVENT_DECODE_DETAIL_JSON_ANY); + reg.register_json_any(super::__PROJECTION_CHECKPOINT_DETAIL_JSON_ANY); + reg.register_json_any(super::__ARTIFACT_DIGEST_DETAIL_JSON_ANY); + reg.register_json_any(super::__OPERATION_LEDGER_DETAIL_JSON_ANY); + reg.register_json_any(super::__UNRECONCILED_WORK_DETAIL_JSON_ANY); + reg.register_json_any(super::__DIAGNOSE_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__INSPECTION_BUDGET_JSON_ANY); + reg.register_json_any(super::__DIAGNOSE_SESSION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__CHECK_OUTCOME_JSON_ANY); + reg.register_json_any(super::__DOCTOR_ERROR_JSON_ANY); + reg.register_json_any(super::__REPAIR_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__REPAIR_TARGET_JSON_ANY); + reg.register_json_any(super::__REPAIR_SESSION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__REPAIR_RESULT_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::OrphanDetailView; +#[doc(inline)] +pub use self::__buffa::view::OrphanDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::OwnershipTraceView; +#[doc(inline)] +pub use self::__buffa::view::OwnershipTraceOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReleaseGateView; +#[doc(inline)] +pub use self::__buffa::view::ReleaseGateOwnedView; +#[doc(inline)] +pub use self::__buffa::view::FindingView; +#[doc(inline)] +pub use self::__buffa::view::FindingOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SubjectRefView; +#[doc(inline)] +pub use self::__buffa::view::SubjectRefOwnedView; +#[doc(inline)] +pub use self::__buffa::view::EventDecodeDetailView; +#[doc(inline)] +pub use self::__buffa::view::EventDecodeDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionCheckpointDetailView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionCheckpointDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ArtifactDigestDetailView; +#[doc(inline)] +pub use self::__buffa::view::ArtifactDigestDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::OperationLedgerDetailView; +#[doc(inline)] +pub use self::__buffa::view::OperationLedgerDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::UnreconciledWorkDetailView; +#[doc(inline)] +pub use self::__buffa::view::UnreconciledWorkDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DiagnoseSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::DiagnoseSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::InspectionBudgetView; +#[doc(inline)] +pub use self::__buffa::view::InspectionBudgetOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DiagnoseSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::DiagnoseSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CheckOutcomeView; +#[doc(inline)] +pub use self::__buffa::view::CheckOutcomeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DoctorErrorView; +#[doc(inline)] +pub use self::__buffa::view::DoctorErrorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RepairSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::RepairSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RepairTargetView; +#[doc(inline)] +pub use self::__buffa::view::RepairTargetOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RepairSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::RepairSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RepairResultView; +#[doc(inline)] +pub use self::__buffa::view::RepairResultOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.__view.rs new file mode 100644 index 0000000000..0764135623 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.__view.rs @@ -0,0 +1,1606 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/orphan.proto + +/// OrphanDetail is the evidence behind an orphan finding. +#[derive(Clone, Debug, Default)] +pub struct OrphanDetailView<'a> { + /// Field 1: `orphan_class` + pub orphan_class: ::buffa::EnumValue, + /// Upload id, artifact id, projection generation, migration id, or lease id, + /// per `orphan_class`. + /// + /// Field 2: `resource_id` + pub resource_id: &'a str, + /// When the resource was created in its store, as the store recorded it. A + /// wall-clock occurrence, not a position derived from append order (D10), + /// because an orphan by definition never reached the log. + /// + /// Field 3: `staged_at` + pub staged_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// How long it has been sitting there, as of the finding's `observed_at`. + /// + /// Field 4: `age` + pub age: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// What was actually checked before calling this unreferenced. + /// + /// Field 5: `trace` + pub trace: ::buffa::MessageFieldView< + super::super::__buffa::view::OwnershipTraceView<'a>, + >, + /// What still has to be true before it can be released. + /// + /// Field 6: `gate` + pub gate: ::buffa::MessageFieldView< + super::super::__buffa::view::ReleaseGateView<'a>, + >, + /// Storage this would return. Unset when the store cannot say, which is + /// ordinary for an incomplete multipart upload and is not zero bytes. + /// + /// Field 7: `reclaimable_bytes` + pub reclaimable_bytes: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> OrphanDetailView<'a> { + /**Whether required field `orphan_class` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_orphan_class(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `resource_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_resource_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `staged_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_staged_at(&self) -> bool { + self.staged_at.is_set() + } + /**Whether required field `age` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_age(&self) -> bool { + self.age.is_set() + } + /**Whether required field `trace` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_trace(&self) -> bool { + self.trace.is_set() + } + /**Whether required field `gate` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_gate(&self) -> bool { + self.gate.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for OrphanDetailView<'a> { + type Owned = super::super::OrphanDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.orphan_class = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.resource_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.staged_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.staged_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.age.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.age = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.trace.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.trace = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.gate.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.gate = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reclaimable_bytes = Some(::buffa::types::decode_uint64(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::OrphanDetail { + orphan_class: self.orphan_class, + resource_id: self.resource_id.to_string(), + staged_at: match self.staged_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + age: match self.age.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + trace: match self.trace.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::OwnershipTrace, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + gate: match self.gate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReleaseGate, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + reclaimable_bytes: self.reclaimable_bytes, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for OrphanDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.orphan_class.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.resource_id) as u64; + if self.staged_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.staged_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.trace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.trace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.gate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.gate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.reclaimable_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.orphan_class.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.resource_id, buf); + if self.staged_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.staged_at.write_to(__cache, buf); + } + if self.age.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.age.write_to(__cache, buf); + } + if self.trace.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.trace.write_to(__cache, buf); + } + if self.gate.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.gate.write_to(__cache, buf); + } + if let Some(v) = self.reclaimable_bytes { + ::buffa::types::put_uint64_field(7u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for OrphanDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("orphanClass", &self.orphan_class)?; + } + { + __map.serialize_entry("resourceId", self.resource_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.staged_at.as_option() { + __map.serialize_entry("stagedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.age.as_option() { + __map.serialize_entry("age", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.trace.as_option() { + __map.serialize_entry("trace", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.gate.as_option() { + __map.serialize_entry("gate", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.reclaimable_bytes { + __map + .serialize_entry( + "reclaimableBytes", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for OrphanDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OrphanDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OrphanDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OrphanDetail"; +} +::buffa::impl_default_view_instance!(OrphanDetailView); +::buffa::impl_view_reborrow!(OrphanDetailView); +/** Self-contained, `'static` owned view of a `OrphanDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`OrphanDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OrphanDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct OrphanDetailOwnedView(::buffa::OwnedView>); +impl OrphanDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OrphanDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OrphanDetailOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::OrphanDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OrphanDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`OrphanDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &OrphanDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::OrphanDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `orphan_class` + #[must_use] + pub fn orphan_class(&self) -> ::buffa::EnumValue { + self.0.reborrow().orphan_class + } + /// Upload id, artifact id, projection generation, migration id, or lease id, + /// per `orphan_class`. + /// + /// Field 2: `resource_id` + #[must_use] + pub fn resource_id(&self) -> &'_ str { + self.0.reborrow().resource_id + } + /// When the resource was created in its store, as the store recorded it. A + /// wall-clock occurrence, not a position derived from append order (D10), + /// because an orphan by definition never reached the log. + /// + /// Field 3: `staged_at` + #[must_use] + pub fn staged_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().staged_at + } + /// How long it has been sitting there, as of the finding's `observed_at`. + /// + /// Field 4: `age` + #[must_use] + pub fn age( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().age + } + /// What was actually checked before calling this unreferenced. + /// + /// Field 5: `trace` + #[must_use] + pub fn trace( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::OwnershipTraceView<'_>, + > { + &self.0.reborrow().trace + } + /// What still has to be true before it can be released. + /// + /// Field 6: `gate` + #[must_use] + pub fn gate( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().gate + } + /// Storage this would return. Unset when the store cannot say, which is + /// ordinary for an incomplete multipart upload and is not zero bytes. + /// + /// Field 7: `reclaimable_bytes` + #[must_use] + pub fn reclaimable_bytes(&self) -> ::core::option::Option { + self.0.reborrow().reclaimable_bytes + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for OrphanDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + OrphanDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: OrphanDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for OrphanDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::OrphanDetail { + type View<'a> = OrphanDetailView<'a>; + type ViewHandle = OrphanDetailOwnedView; +} +impl ::serde::Serialize for OrphanDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// OwnershipTrace is what the orphan check looked at, and how far it got. +/// +/// This message is the difference between a finding and a guess. "No reference +/// found" is only meaningful alongside where the search ran and where it +/// stopped, and a check that scanned four of a tenant's streams produces the +/// same empty result as one that scanned all of them. +#[derive(Clone, Debug, Default)] +pub struct OwnershipTraceView<'a> { + /// Field 1: `completeness` + pub completeness: ::buffa::EnumValue, + /// Streams the trace read to completion. + /// + /// Field 2: `streams_scanned` + pub streams_scanned: u32, + /// Streams in scope the trace could not read. Any non-zero value makes the + /// result non-exhaustive no matter how many streams were scanned, because the + /// reference could be in exactly one of them. + /// + /// Field 3: `streams_unreadable` + pub streams_unreadable: u32, + /// Position the trace scanned through. + /// + /// Field 4: `scanned_through_watermark` + pub scanned_through_watermark: u64, + /// Head at the time the trace ran. Above `scanned_through_watermark` means + /// events were appended during the scan, and a reference could be in the gap. + /// + /// Field 5: `source_high_watermark` + pub source_high_watermark: u64, + /// Position the slowest projector needed for this trace had applied through. + /// + /// A trace that consults derived state is only as complete as that state. A + /// projector behind the scan makes the trace's answer a statement about + /// history the projector has already seen, which is not the same as the + /// history that exists. + /// + /// Field 6: `projector_applied_through` + pub projector_applied_through: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> OwnershipTraceView<'a> { + /**Whether required field `completeness` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `streams_scanned` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_streams_scanned(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `streams_unreadable` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_streams_unreadable(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `scanned_through_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_scanned_through_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `source_high_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_high_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `projector_applied_through` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projector_applied_through(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for OwnershipTraceView<'a> { + type Owned = super::super::OwnershipTrace; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.streams_scanned = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.streams_unreadable = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.scanned_through_watermark = ::buffa::types::decode_uint64( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source_high_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.projector_applied_through = ::buffa::types::decode_uint64( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 32u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::OwnershipTrace { + completeness: self.completeness, + streams_scanned: self.streams_scanned, + streams_unreadable: self.streams_unreadable, + scanned_through_watermark: self.scanned_through_watermark, + source_high_watermark: self.source_high_watermark, + projector_applied_through: self.projector_applied_through, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for OwnershipTraceView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.streams_scanned) as u64; + size + += 1u64 + ::buffa::types::uint32_encoded_len(self.streams_unreadable) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.scanned_through_watermark) + as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.source_high_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.projector_applied_through) + as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(2u32, self.streams_scanned, buf); + ::buffa::types::put_uint32_field(3u32, self.streams_unreadable, buf); + ::buffa::types::put_uint64_field(4u32, self.scanned_through_watermark, buf); + ::buffa::types::put_uint64_field(5u32, self.source_high_watermark, buf); + ::buffa::types::put_uint64_field(6u32, self.projector_applied_through, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for OwnershipTraceView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("completeness", &self.completeness)?; + } + { + __map + .serialize_entry( + "streamsScanned", + &::buffa::json_helpers::ProtoJson(&self.streams_scanned), + )?; + } + { + __map + .serialize_entry( + "streamsUnreadable", + &::buffa::json_helpers::ProtoJson(&self.streams_unreadable), + )?; + } + { + __map + .serialize_entry( + "scannedThroughWatermark", + &::buffa::json_helpers::ProtoJson(&self.scanned_through_watermark), + )?; + } + { + __map + .serialize_entry( + "sourceHighWatermark", + &::buffa::json_helpers::ProtoJson(&self.source_high_watermark), + )?; + } + { + __map + .serialize_entry( + "projectorAppliedThrough", + &::buffa::json_helpers::ProtoJson(&self.projector_applied_through), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for OwnershipTraceView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OwnershipTrace"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace"; +} +::buffa::impl_default_view_instance!(OwnershipTraceView); +::buffa::impl_view_reborrow!(OwnershipTraceView); +/** Self-contained, `'static` owned view of a `OwnershipTrace` message. + + Wraps [`::buffa::OwnedView`]`<`[`OwnershipTraceView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OwnershipTraceView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct OwnershipTraceOwnedView(::buffa::OwnedView>); +impl OwnershipTraceOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OwnershipTraceOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OwnershipTraceOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::OwnershipTrace, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OwnershipTraceOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`OwnershipTraceView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &OwnershipTraceView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::OwnershipTrace { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `completeness` + #[must_use] + pub fn completeness(&self) -> ::buffa::EnumValue { + self.0.reborrow().completeness + } + /// Streams the trace read to completion. + /// + /// Field 2: `streams_scanned` + #[must_use] + pub fn streams_scanned(&self) -> u32 { + self.0.reborrow().streams_scanned + } + /// Streams in scope the trace could not read. Any non-zero value makes the + /// result non-exhaustive no matter how many streams were scanned, because the + /// reference could be in exactly one of them. + /// + /// Field 3: `streams_unreadable` + #[must_use] + pub fn streams_unreadable(&self) -> u32 { + self.0.reborrow().streams_unreadable + } + /// Position the trace scanned through. + /// + /// Field 4: `scanned_through_watermark` + #[must_use] + pub fn scanned_through_watermark(&self) -> u64 { + self.0.reborrow().scanned_through_watermark + } + /// Head at the time the trace ran. Above `scanned_through_watermark` means + /// events were appended during the scan, and a reference could be in the gap. + /// + /// Field 5: `source_high_watermark` + #[must_use] + pub fn source_high_watermark(&self) -> u64 { + self.0.reborrow().source_high_watermark + } + /// Position the slowest projector needed for this trace had applied through. + /// + /// A trace that consults derived state is only as complete as that state. A + /// projector behind the scan makes the trace's answer a statement about + /// history the projector has already seen, which is not the same as the + /// history that exists. + /// + /// Field 6: `projector_applied_through` + #[must_use] + pub fn projector_applied_through(&self) -> u64 { + self.0.reborrow().projector_applied_through + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for OwnershipTraceOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + OwnershipTraceOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: OwnershipTraceOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for OwnershipTraceOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::OwnershipTrace { + type View<'a> = OwnershipTraceView<'a>; + type ViewHandle = OwnershipTraceOwnedView; +} +impl ::serde::Serialize for OwnershipTraceOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReleaseGate is what stands between an orphan finding and deleting something. +/// +/// Nothing is released on age alone and nothing is released on absence of +/// references alone. Both are necessary and neither is sufficient, which is why +/// the outcome is a single value rather than a set of flags a caller could read +/// selectively. +#[derive(Clone, Debug, Default)] +pub struct ReleaseGateView<'a> { + /// Field 1: `outcome` + pub outcome: ::buffa::EnumValue, + /// How old a resource of this class must be before release is considered. + /// + /// Field 2: `minimum_age` + pub minimum_age: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// How long an append can remain indeterminate before its outcome is settled + /// one way or the other. + /// + /// This is the number that makes the whole gate correct. An append whose write + /// state is unknown may still land, and if it lands it carries a reference to + /// a resource that a cleanup pass has already decided nothing points at. So + /// `minimum_age` has to exceed this window, and a resource inside it is held + /// regardless of how thoroughly it was traced: the trace was accurate and the + /// history was not finished happening. + /// + /// Field 3: `indeterminacy_window` + pub indeterminacy_window: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// Earliest time this could become releasable, if nothing changes. Unset when + /// waiting will not help, which is the case for every outcome that depends on + /// a fault being fixed rather than on time passing. + /// + /// Field 4: `releasable_after` + pub releasable_after: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReleaseGateView<'a> { + /**Whether required field `outcome` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `minimum_age` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_minimum_age(&self) -> bool { + self.minimum_age.is_set() + } + /**Whether required field `indeterminacy_window` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_indeterminacy_window(&self) -> bool { + self.indeterminacy_window.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ReleaseGateView<'a> { + type Owned = super::super::ReleaseGate; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.minimum_age.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.minimum_age = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.indeterminacy_window.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.indeterminacy_window = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.releasable_after.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.releasable_after = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReleaseGate { + outcome: self.outcome, + minimum_age: match self.minimum_age.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + indeterminacy_window: match self.indeterminacy_window.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + releasable_after: match self.releasable_after.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReleaseGateView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.minimum_age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minimum_age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminacy_window.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminacy_window.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.releasable_after.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.releasable_after.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.outcome.to_i32(), buf); + if self.minimum_age.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minimum_age.write_to(__cache, buf); + } + if self.indeterminacy_window.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminacy_window.write_to(__cache, buf); + } + if self.releasable_after.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.releasable_after.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReleaseGateView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("outcome", &self.outcome)?; + } + { + if let ::core::option::Option::Some(__v) = self.minimum_age.as_option() { + __map.serialize_entry("minimumAge", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .indeterminacy_window + .as_option() + { + __map.serialize_entry("indeterminacyWindow", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.releasable_after.as_option() + { + __map.serialize_entry("releasableAfter", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReleaseGateView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ReleaseGate"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ReleaseGate"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ReleaseGate"; +} +::buffa::impl_default_view_instance!(ReleaseGateView); +::buffa::impl_view_reborrow!(ReleaseGateView); +/** Self-contained, `'static` owned view of a `ReleaseGate` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReleaseGateView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReleaseGateView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReleaseGateOwnedView(::buffa::OwnedView>); +impl ReleaseGateOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReleaseGateOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReleaseGateOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReleaseGate, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReleaseGateOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReleaseGateView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReleaseGateView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReleaseGate { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `outcome` + #[must_use] + pub fn outcome(&self) -> ::buffa::EnumValue { + self.0.reborrow().outcome + } + /// How old a resource of this class must be before release is considered. + /// + /// Field 2: `minimum_age` + #[must_use] + pub fn minimum_age( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().minimum_age + } + /// How long an append can remain indeterminate before its outcome is settled + /// one way or the other. + /// + /// This is the number that makes the whole gate correct. An append whose write + /// state is unknown may still land, and if it lands it carries a reference to + /// a resource that a cleanup pass has already decided nothing points at. So + /// `minimum_age` has to exceed this window, and a resource inside it is held + /// regardless of how thoroughly it was traced: the trace was accurate and the + /// history was not finished happening. + /// + /// Field 3: `indeterminacy_window` + #[must_use] + pub fn indeterminacy_window( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().indeterminacy_window + } + /// Earliest time this could become releasable, if nothing changes. Unset when + /// waiting will not help, which is the case for every outcome that depends on + /// a fault being fixed rather than on time passing. + /// + /// Field 4: `releasable_after` + #[must_use] + pub fn releasable_after( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().releasable_after + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReleaseGateOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReleaseGateOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReleaseGateOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReleaseGateOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReleaseGate { + type View<'a> = ReleaseGateView<'a>; + type ViewHandle = ReleaseGateOwnedView; +} +impl ::serde::Serialize for ReleaseGateOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.rs new file mode 100644 index 0000000000..d3dae57b3b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.orphan.rs @@ -0,0 +1,1426 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/orphan.proto + +/// Orphan reporting for the doctor. +/// +/// An orphan is a resource that was staged for a write that never landed. The +/// canonical shape is an artifact upload that succeeded followed by an append +/// that failed: the bytes are durable, nothing references them, and nothing ever +/// will. Left alone they accumulate; deleted carelessly they take live content +/// with them. +/// +/// Every message here exists to make the second failure hard. The point is not +/// to find candidates, which is easy, but to state what was actually traced and +/// what is still holding a release back, so that deleting something is a +/// decision an operator makes against evidence rather than against a count. +/// +/// OrphanClass is what kind of resource was left behind. +/// +/// They are enumerated separately rather than collapsed into "unreferenced +/// thing" because they have different owners, different ways of being +/// referenced, and different consequences for getting it wrong. Releasing an +/// abandoned projection generation costs a rebuild. Releasing a claim check that +/// was about to be referenced destroys the only copy of a command's output. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum OrphanClass { + ORPHAN_CLASS_UNSPECIFIED = 0i32, + /// A multipart upload with parts written and no completion. It holds storage, + /// it has no digest yet, and no event can reference it because the object it + /// would name does not exist. + ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD = 1i32, + /// A completed object with a digest that no event in any stream references. + /// + /// The dangerous one. Content-addressed storage means the same bytes can be + /// reachable through a stream nobody thought to scan, so this class is the + /// reason ownership has to be traced rather than searched for. + ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK = 2i32, + /// Materialized state belonging to a projection generation that is neither + /// current nor being rebuilt. Disposable by construction: the stream can + /// produce it again. + ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION = 3i32, + /// Staging state from a migration that has since finished. It was never the + /// source of truth, and it stops being a fallback once the migration is done. + ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING = 4i32, + /// A reconciliation lease past its expiry whose holder never returned. + /// + /// Releasing this one is not a deletion, it is a handoff: the work the lease + /// covered still needs settling, and reclaiming the lease is what lets someone + /// else settle it. + ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE = 5i32, +} +impl OrphanClass { + ///Idiomatic alias for [`Self::ORPHAN_CLASS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ORPHAN_CLASS_UNSPECIFIED; + ///Idiomatic alias for [`Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UncommittedMultipartUpload: Self = Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD; + ///Idiomatic alias for [`Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnreferencedClaimCheck: Self = Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK; + ///Idiomatic alias for [`Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AbandonedProjectionGeneration: Self = Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION; + ///Idiomatic alias for [`Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CompletedMigrationStaging: Self = Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING; + ///Idiomatic alias for [`Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ExpiredReconciliationLease: Self = Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE; +} +impl ::core::default::Default for OrphanClass { + fn default() -> Self { + Self::ORPHAN_CLASS_UNSPECIFIED + } +} +impl ::serde::Serialize for OrphanClass { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for OrphanClass { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = OrphanClass; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(OrphanClass)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for OrphanClass { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for OrphanClass { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ORPHAN_CLASS_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD, + ) + } + 2i32 => { + ::core::option::Option::Some(Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK) + } + 3i32 => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING, + ) + } + 5i32 => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ORPHAN_CLASS_UNSPECIFIED => "ORPHAN_CLASS_UNSPECIFIED", + Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD => { + "ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD" + } + Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK => { + "ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK" + } + Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION => { + "ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION" + } + Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING => { + "ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING" + } + Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE => { + "ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ORPHAN_CLASS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ORPHAN_CLASS_UNSPECIFIED) + } + "ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD" => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD, + ) + } + "ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK" => { + ::core::option::Option::Some(Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK) + } + "ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION" => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION, + ) + } + "ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING" => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING, + ) + } + "ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE" => { + ::core::option::Option::Some( + Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ORPHAN_CLASS_UNSPECIFIED, + Self::ORPHAN_CLASS_UNCOMMITTED_MULTIPART_UPLOAD, + Self::ORPHAN_CLASS_UNREFERENCED_CLAIM_CHECK, + Self::ORPHAN_CLASS_ABANDONED_PROJECTION_GENERATION, + Self::ORPHAN_CLASS_COMPLETED_MIGRATION_STAGING, + Self::ORPHAN_CLASS_EXPIRED_RECONCILIATION_LEASE, + ] + } +} +/// TraceCompleteness is how much of the search space the trace actually covered. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TraceCompleteness { + /// Unknown coverage. Treat as INCOMPLETE. + TRACE_COMPLETENESS_UNSPECIFIED = 0i32, + /// Every stream in scope was read to the head observed at scan time, and + /// every projector consulted was current with it. + TRACE_COMPLETENESS_EXHAUSTIVE = 1i32, + /// Coverage was cut short by a budget: a time limit, a stream limit, a byte + /// limit. Whatever was scanned is accurate, and the unscanned part is unknown. + TRACE_COMPLETENESS_BOUNDED = 2i32, + /// Something in scope could not be read at all. Distinct from BOUNDED because + /// a bounded trace can be finished by granting more budget, and this one + /// cannot be finished until the fault is fixed. + TRACE_COMPLETENESS_INCOMPLETE = 3i32, +} +impl TraceCompleteness { + ///Idiomatic alias for [`Self::TRACE_COMPLETENESS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TRACE_COMPLETENESS_UNSPECIFIED; + ///Idiomatic alias for [`Self::TRACE_COMPLETENESS_EXHAUSTIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Exhaustive: Self = Self::TRACE_COMPLETENESS_EXHAUSTIVE; + ///Idiomatic alias for [`Self::TRACE_COMPLETENESS_BOUNDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Bounded: Self = Self::TRACE_COMPLETENESS_BOUNDED; + ///Idiomatic alias for [`Self::TRACE_COMPLETENESS_INCOMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Incomplete: Self = Self::TRACE_COMPLETENESS_INCOMPLETE; +} +impl ::core::default::Default for TraceCompleteness { + fn default() -> Self { + Self::TRACE_COMPLETENESS_UNSPECIFIED + } +} +impl ::serde::Serialize for TraceCompleteness { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TraceCompleteness { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TraceCompleteness; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TraceCompleteness) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TraceCompleteness { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TraceCompleteness { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TRACE_COMPLETENESS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TRACE_COMPLETENESS_EXHAUSTIVE), + 2i32 => ::core::option::Option::Some(Self::TRACE_COMPLETENESS_BOUNDED), + 3i32 => ::core::option::Option::Some(Self::TRACE_COMPLETENESS_INCOMPLETE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TRACE_COMPLETENESS_UNSPECIFIED => "TRACE_COMPLETENESS_UNSPECIFIED", + Self::TRACE_COMPLETENESS_EXHAUSTIVE => "TRACE_COMPLETENESS_EXHAUSTIVE", + Self::TRACE_COMPLETENESS_BOUNDED => "TRACE_COMPLETENESS_BOUNDED", + Self::TRACE_COMPLETENESS_INCOMPLETE => "TRACE_COMPLETENESS_INCOMPLETE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TRACE_COMPLETENESS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TRACE_COMPLETENESS_UNSPECIFIED) + } + "TRACE_COMPLETENESS_EXHAUSTIVE" => { + ::core::option::Option::Some(Self::TRACE_COMPLETENESS_EXHAUSTIVE) + } + "TRACE_COMPLETENESS_BOUNDED" => { + ::core::option::Option::Some(Self::TRACE_COMPLETENESS_BOUNDED) + } + "TRACE_COMPLETENESS_INCOMPLETE" => { + ::core::option::Option::Some(Self::TRACE_COMPLETENESS_INCOMPLETE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TRACE_COMPLETENESS_UNSPECIFIED, + Self::TRACE_COMPLETENESS_EXHAUSTIVE, + Self::TRACE_COMPLETENESS_BOUNDED, + Self::TRACE_COMPLETENESS_INCOMPLETE, + ] + } +} +/// GateOutcome is whether this orphan may be released now, and if not, why not. +/// +/// The zero value holds and RELEASABLE is last, so a reader that does not +/// recognize a variant keeps the resource. Getting this backwards would make an +/// unknown enum value a deletion. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum GateOutcome { + /// Unknown outcome. Hold. + GATE_OUTCOME_UNSPECIFIED = 0i32, + /// Younger than `minimum_age`. + GATE_OUTCOME_HELD_TOO_YOUNG = 1i32, + /// Inside the indeterminacy window of an append that has not settled. The + /// reference may still arrive. + GATE_OUTCOME_HELD_INDETERMINATE_APPEND = 2i32, + /// The ownership trace did not cover the search space, so "unreferenced" has + /// not actually been established. + GATE_OUTCOME_HELD_TRACE_INCOMPLETE = 3i32, + /// A projector the trace depends on is behind the stream head. Held rather + /// than reported as incomplete, because this one resolves on its own once the + /// projector catches up. + GATE_OUTCOME_HELD_PROJECTOR_BEHIND = 4i32, + /// Old enough, exhaustively traced, no unsettled append in range. A repair may + /// release it. + /// + /// Still not an instruction. The doctor observes and never mutates; releasing + /// is a RepairSession call naming this finding, and the gate is re-evaluated + /// then, because everything it asserts can stop being true in the interval. + GATE_OUTCOME_RELEASABLE = 5i32, +} +impl GateOutcome { + ///Idiomatic alias for [`Self::GATE_OUTCOME_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::GATE_OUTCOME_UNSPECIFIED; + ///Idiomatic alias for [`Self::GATE_OUTCOME_HELD_TOO_YOUNG`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const HeldTooYoung: Self = Self::GATE_OUTCOME_HELD_TOO_YOUNG; + ///Idiomatic alias for [`Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const HeldIndeterminateAppend: Self = Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND; + ///Idiomatic alias for [`Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const HeldTraceIncomplete: Self = Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE; + ///Idiomatic alias for [`Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const HeldProjectorBehind: Self = Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND; + ///Idiomatic alias for [`Self::GATE_OUTCOME_RELEASABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Releasable: Self = Self::GATE_OUTCOME_RELEASABLE; +} +impl ::core::default::Default for GateOutcome { + fn default() -> Self { + Self::GATE_OUTCOME_UNSPECIFIED + } +} +impl ::serde::Serialize for GateOutcome { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for GateOutcome { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = GateOutcome; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(GateOutcome)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for GateOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for GateOutcome { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::GATE_OUTCOME_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_TOO_YOUNG), + 2i32 => { + ::core::option::Option::Some( + Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND, + ) + } + 3i32 => { + ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE) + } + 4i32 => { + ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND) + } + 5i32 => ::core::option::Option::Some(Self::GATE_OUTCOME_RELEASABLE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::GATE_OUTCOME_UNSPECIFIED => "GATE_OUTCOME_UNSPECIFIED", + Self::GATE_OUTCOME_HELD_TOO_YOUNG => "GATE_OUTCOME_HELD_TOO_YOUNG", + Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND => { + "GATE_OUTCOME_HELD_INDETERMINATE_APPEND" + } + Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE => { + "GATE_OUTCOME_HELD_TRACE_INCOMPLETE" + } + Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND => { + "GATE_OUTCOME_HELD_PROJECTOR_BEHIND" + } + Self::GATE_OUTCOME_RELEASABLE => "GATE_OUTCOME_RELEASABLE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "GATE_OUTCOME_UNSPECIFIED" => { + ::core::option::Option::Some(Self::GATE_OUTCOME_UNSPECIFIED) + } + "GATE_OUTCOME_HELD_TOO_YOUNG" => { + ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_TOO_YOUNG) + } + "GATE_OUTCOME_HELD_INDETERMINATE_APPEND" => { + ::core::option::Option::Some( + Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND, + ) + } + "GATE_OUTCOME_HELD_TRACE_INCOMPLETE" => { + ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE) + } + "GATE_OUTCOME_HELD_PROJECTOR_BEHIND" => { + ::core::option::Option::Some(Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND) + } + "GATE_OUTCOME_RELEASABLE" => { + ::core::option::Option::Some(Self::GATE_OUTCOME_RELEASABLE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::GATE_OUTCOME_UNSPECIFIED, + Self::GATE_OUTCOME_HELD_TOO_YOUNG, + Self::GATE_OUTCOME_HELD_INDETERMINATE_APPEND, + Self::GATE_OUTCOME_HELD_TRACE_INCOMPLETE, + Self::GATE_OUTCOME_HELD_PROJECTOR_BEHIND, + Self::GATE_OUTCOME_RELEASABLE, + ] + } +} +/// OrphanDetail is the evidence behind an orphan finding. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct OrphanDetail { + /// Field 1: `orphan_class` + #[serde( + rename = "orphanClass", + alias = "orphan_class", + with = "::buffa::json_helpers::proto_enum" + )] + pub orphan_class: ::buffa::EnumValue, + /// Upload id, artifact id, projection generation, migration id, or lease id, + /// per `orphan_class`. + /// + /// Field 2: `resource_id` + #[serde( + rename = "resourceId", + alias = "resource_id", + with = "::buffa::json_helpers::proto_string" + )] + pub resource_id: ::buffa::alloc::string::String, + /// When the resource was created in its store, as the store recorded it. A + /// wall-clock occurrence, not a position derived from append order (D10), + /// because an orphan by definition never reached the log. + /// + /// Field 3: `staged_at` + #[serde(rename = "stagedAt", alias = "staged_at")] + pub staged_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// How long it has been sitting there, as of the finding's `observed_at`. + /// + /// Field 4: `age` + #[serde(rename = "age")] + pub age: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// What was actually checked before calling this unreferenced. + /// + /// Field 5: `trace` + #[serde(rename = "trace")] + pub trace: ::buffa::MessageField>, + /// What still has to be true before it can be released. + /// + /// Field 6: `gate` + #[serde(rename = "gate")] + pub gate: ::buffa::MessageField>, + /// Storage this would return. Unset when the store cannot say, which is + /// ordinary for an incomplete multipart upload and is not zero bytes. + /// + /// Field 7: `reclaimable_bytes` + #[serde( + rename = "reclaimableBytes", + alias = "reclaimable_bytes", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub reclaimable_bytes: ::core::option::Option, +} +impl ::core::fmt::Debug for OrphanDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OrphanDetail") + .field("orphan_class", &self.orphan_class) + .field("resource_id", &self.resource_id) + .field("staged_at", &self.staged_at) + .field("age", &self.age) + .field("trace", &self.trace) + .field("gate", &self.gate) + .field("reclaimable_bytes", &self.reclaimable_bytes) + .finish() + } +} +impl OrphanDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OrphanDetail"; +} +impl OrphanDetail { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reclaimable_bytes`] to `Some(value)`, consuming and returning `self`. + pub fn with_reclaimable_bytes(mut self, value: u64) -> Self { + self.reclaimable_bytes = Some(value); + self + } +} +::buffa::impl_default_instance!(OrphanDetail); +impl ::buffa::MessageName for OrphanDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OrphanDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OrphanDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OrphanDetail"; +} +impl ::buffa::Message for OrphanDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.orphan_class.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.resource_id) as u64; + if self.staged_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.staged_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.trace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.trace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.gate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.gate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.reclaimable_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.orphan_class.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.resource_id, buf); + if self.staged_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.staged_at.write_to(__cache, buf); + } + if self.age.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.age.write_to(__cache, buf); + } + if self.trace.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.trace.write_to(__cache, buf); + } + if self.gate.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.gate.write_to(__cache, buf); + } + if let Some(v) = self.reclaimable_bytes { + ::buffa::types::put_uint64_field(7u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.orphan_class = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.resource_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.staged_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.age.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.trace.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.gate.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reclaimable_bytes = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.orphan_class = ::buffa::EnumValue::from(0); + self.resource_id.clear(); + self.staged_at = ::buffa::MessageField::none(); + self.age = ::buffa::MessageField::none(); + self.trace = ::buffa::MessageField::none(); + self.gate = ::buffa::MessageField::none(); + self.reclaimable_bytes = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for OrphanDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ORPHAN_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OrphanDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// OwnershipTrace is what the orphan check looked at, and how far it got. +/// +/// This message is the difference between a finding and a guess. "No reference +/// found" is only meaningful alongside where the search ran and where it +/// stopped, and a check that scanned four of a tenant's streams produces the +/// same empty result as one that scanned all of them. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct OwnershipTrace { + /// Field 1: `completeness` + #[serde(rename = "completeness", with = "::buffa::json_helpers::proto_enum")] + pub completeness: ::buffa::EnumValue, + /// Streams the trace read to completion. + /// + /// Field 2: `streams_scanned` + #[serde( + rename = "streamsScanned", + alias = "streams_scanned", + with = "::buffa::json_helpers::uint32" + )] + pub streams_scanned: u32, + /// Streams in scope the trace could not read. Any non-zero value makes the + /// result non-exhaustive no matter how many streams were scanned, because the + /// reference could be in exactly one of them. + /// + /// Field 3: `streams_unreadable` + #[serde( + rename = "streamsUnreadable", + alias = "streams_unreadable", + with = "::buffa::json_helpers::uint32" + )] + pub streams_unreadable: u32, + /// Position the trace scanned through. + /// + /// Field 4: `scanned_through_watermark` + #[serde( + rename = "scannedThroughWatermark", + alias = "scanned_through_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub scanned_through_watermark: u64, + /// Head at the time the trace ran. Above `scanned_through_watermark` means + /// events were appended during the scan, and a reference could be in the gap. + /// + /// Field 5: `source_high_watermark` + #[serde( + rename = "sourceHighWatermark", + alias = "source_high_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub source_high_watermark: u64, + /// Position the slowest projector needed for this trace had applied through. + /// + /// A trace that consults derived state is only as complete as that state. A + /// projector behind the scan makes the trace's answer a statement about + /// history the projector has already seen, which is not the same as the + /// history that exists. + /// + /// Field 6: `projector_applied_through` + #[serde( + rename = "projectorAppliedThrough", + alias = "projector_applied_through", + with = "::buffa::json_helpers::uint64" + )] + pub projector_applied_through: u64, +} +impl ::core::fmt::Debug for OwnershipTrace { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OwnershipTrace") + .field("completeness", &self.completeness) + .field("streams_scanned", &self.streams_scanned) + .field("streams_unreadable", &self.streams_unreadable) + .field("scanned_through_watermark", &self.scanned_through_watermark) + .field("source_high_watermark", &self.source_high_watermark) + .field("projector_applied_through", &self.projector_applied_through) + .finish() + } +} +impl OwnershipTrace { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace"; +} +::buffa::impl_default_instance!(OwnershipTrace); +impl ::buffa::MessageName for OwnershipTrace { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "OwnershipTrace"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace"; +} +impl ::buffa::Message for OwnershipTrace { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.streams_scanned) as u64; + size + += 1u64 + ::buffa::types::uint32_encoded_len(self.streams_unreadable) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.scanned_through_watermark) + as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.source_high_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.projector_applied_through) + as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(2u32, self.streams_scanned, buf); + ::buffa::types::put_uint32_field(3u32, self.streams_unreadable, buf); + ::buffa::types::put_uint64_field(4u32, self.scanned_through_watermark, buf); + ::buffa::types::put_uint64_field(5u32, self.source_high_watermark, buf); + ::buffa::types::put_uint64_field(6u32, self.projector_applied_through, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.streams_scanned = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.streams_unreadable = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.scanned_through_watermark = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source_high_watermark = ::buffa::types::decode_uint64(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.projector_applied_through = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.completeness = ::buffa::EnumValue::from(0); + self.streams_scanned = 0u32; + self.streams_unreadable = 0u32; + self.scanned_through_watermark = 0u64; + self.source_high_watermark = 0u64; + self.projector_applied_through = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for OwnershipTrace { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OWNERSHIP_TRACE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.OwnershipTrace", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReleaseGate is what stands between an orphan finding and deleting something. +/// +/// Nothing is released on age alone and nothing is released on absence of +/// references alone. Both are necessary and neither is sufficient, which is why +/// the outcome is a single value rather than a set of flags a caller could read +/// selectively. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReleaseGate { + /// Field 1: `outcome` + #[serde(rename = "outcome", with = "::buffa::json_helpers::proto_enum")] + pub outcome: ::buffa::EnumValue, + /// How old a resource of this class must be before release is considered. + /// + /// Field 2: `minimum_age` + #[serde(rename = "minimumAge", alias = "minimum_age")] + pub minimum_age: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// How long an append can remain indeterminate before its outcome is settled + /// one way or the other. + /// + /// This is the number that makes the whole gate correct. An append whose write + /// state is unknown may still land, and if it lands it carries a reference to + /// a resource that a cleanup pass has already decided nothing points at. So + /// `minimum_age` has to exceed this window, and a resource inside it is held + /// regardless of how thoroughly it was traced: the trace was accurate and the + /// history was not finished happening. + /// + /// Field 3: `indeterminacy_window` + #[serde(rename = "indeterminacyWindow", alias = "indeterminacy_window")] + pub indeterminacy_window: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// Earliest time this could become releasable, if nothing changes. Unset when + /// waiting will not help, which is the case for every outcome that depends on + /// a fault being fixed rather than on time passing. + /// + /// Field 4: `releasable_after` + #[serde( + rename = "releasableAfter", + alias = "releasable_after", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub releasable_after: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ReleaseGate { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReleaseGate") + .field("outcome", &self.outcome) + .field("minimum_age", &self.minimum_age) + .field("indeterminacy_window", &self.indeterminacy_window) + .field("releasable_after", &self.releasable_after) + .finish() + } +} +impl ReleaseGate { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ReleaseGate"; +} +::buffa::impl_default_instance!(ReleaseGate); +impl ::buffa::MessageName for ReleaseGate { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "ReleaseGate"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.ReleaseGate"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ReleaseGate"; +} +impl ::buffa::Message for ReleaseGate { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.minimum_age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minimum_age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminacy_window.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminacy_window.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.releasable_after.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.releasable_after.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.outcome.to_i32(), buf); + if self.minimum_age.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minimum_age.write_to(__cache, buf); + } + if self.indeterminacy_window.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminacy_window.write_to(__cache, buf); + } + if self.releasable_after.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.releasable_after.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.minimum_age.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.indeterminacy_window.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.releasable_after.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.outcome = ::buffa::EnumValue::from(0); + self.minimum_age = ::buffa::MessageField::none(); + self.indeterminacy_window = ::buffa::MessageField::none(); + self.releasable_after = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReleaseGate { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RELEASE_GATE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.ReleaseGate", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_action.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_action.rs new file mode 100644 index 0000000000..1fd61fe30e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_action.rs @@ -0,0 +1,292 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/repair_action.proto + +/// RepairAction is something the doctor can do about a finding. +/// +/// Every value in this enum operates on derived state: a projection, a +/// checkpoint, a snapshot, a claim. That is not a coincidence and it is not a +/// starting point to be extended later. +/// +/// The event stream is the source of truth and it is append-only. A repair that +/// edited, deleted, or reordered events would make the log depend on the tooling +/// built to inspect it, and every guarantee that rests on replay determinism +/// would rest instead on nobody having run the wrong repair. So no such action +/// exists here, and adding one is a decision about the architecture rather than +/// an addition to a list. +/// +/// The corollary catches the case operators most often expect to find here. +/// Reconciling a tool call that never recorded an outcome is not a repair. It is +/// CompleteToolCall or FailToolCall, an ordinary command through the ordinary +/// decider, subject to the ordinary invariants. Routing it through the doctor +/// would let an operator write history without passing the rules that make the +/// history mean anything. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RepairAction { + REPAIR_ACTION_UNSPECIFIED = 0i32, + /// Rebuild a projection from the stream under a new generation. The workhorse: + /// it addresses most DEGRADED findings and it is safe because the input is + /// authoritative and the output is disposable. + REPAIR_ACTION_REBUILD_PROJECTION = 1i32, + /// Mark a projection generation unreadable so reads fail closed instead of + /// serving state known to be wrong. Used when a rebuild is not immediately + /// possible, and it makes the situation worse for readers on purpose: a + /// refused read is recoverable, a believed wrong answer is not. + REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION = 2i32, + /// Reset a projection checkpoint to the position the materialized view + /// actually reflects, so the projector reprocesses the gap it skipped. + REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT = 3i32, + /// Discard a snapshot so the aggregate is folded from events again. Always + /// safe and never necessary for correctness, since a snapshot is a cache. + REPAIR_ACTION_DISCARD_SNAPSHOT = 4i32, + /// Recompute an artifact's digest from storage. This is a re-observation, not + /// a mutation, and it exists as an action because a digest finding is often a + /// transient read failure rather than data loss. + REPAIR_ACTION_REVERIFY_ARTIFACT = 5i32, + /// Release an artifact claim or multipart upload that references nothing + /// durable. The only action here that destroys anything, which is why the + /// finding it answers requires tracing durable ownership rather than a + /// reference search. + REPAIR_ACTION_RELEASE_ORPHANED_CLAIM = 6i32, + /// Discard derived state belonging to a computation that no longer runs: an + /// abandoned projection generation, staging from a completed migration. + /// + /// Distinct from releasing a claim, which is the only other action that + /// destroys anything, because this one destroys something reproducible. The + /// gate on the finding still has to pass: the cheap thing to get wrong here is + /// discarding the generation a rebuild is currently writing into. + REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE = 7i32, + /// Reclaim an expired reconciliation lease so another worker can settle the + /// operation it covered. A handoff rather than a deletion: the work still + /// exists and still needs an outcome. + REPAIR_ACTION_RECLAIM_EXPIRED_LEASE = 8i32, +} +impl RepairAction { + ///Idiomatic alias for [`Self::REPAIR_ACTION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::REPAIR_ACTION_UNSPECIFIED; + ///Idiomatic alias for [`Self::REPAIR_ACTION_REBUILD_PROJECTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RebuildProjection: Self = Self::REPAIR_ACTION_REBUILD_PROJECTION; + ///Idiomatic alias for [`Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const QuarantineProjectionGeneration: Self = Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION; + ///Idiomatic alias for [`Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ResetProjectionCheckpoint: Self = Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT; + ///Idiomatic alias for [`Self::REPAIR_ACTION_DISCARD_SNAPSHOT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DiscardSnapshot: Self = Self::REPAIR_ACTION_DISCARD_SNAPSHOT; + ///Idiomatic alias for [`Self::REPAIR_ACTION_REVERIFY_ARTIFACT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ReverifyArtifact: Self = Self::REPAIR_ACTION_REVERIFY_ARTIFACT; + ///Idiomatic alias for [`Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ReleaseOrphanedClaim: Self = Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM; + ///Idiomatic alias for [`Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DiscardOrphanedDerivedState: Self = Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE; + ///Idiomatic alias for [`Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ReclaimExpiredLease: Self = Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE; +} +impl ::core::default::Default for RepairAction { + fn default() -> Self { + Self::REPAIR_ACTION_UNSPECIFIED + } +} +impl ::serde::Serialize for RepairAction { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RepairAction { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RepairAction; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(RepairAction)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairAction { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RepairAction { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::REPAIR_ACTION_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::REPAIR_ACTION_REBUILD_PROJECTION), + 2i32 => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT, + ) + } + 4i32 => ::core::option::Option::Some(Self::REPAIR_ACTION_DISCARD_SNAPSHOT), + 5i32 => ::core::option::Option::Some(Self::REPAIR_ACTION_REVERIFY_ARTIFACT), + 6i32 => { + ::core::option::Option::Some(Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM) + } + 7i32 => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE, + ) + } + 8i32 => { + ::core::option::Option::Some(Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::REPAIR_ACTION_UNSPECIFIED => "REPAIR_ACTION_UNSPECIFIED", + Self::REPAIR_ACTION_REBUILD_PROJECTION => "REPAIR_ACTION_REBUILD_PROJECTION", + Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION => { + "REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION" + } + Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT => { + "REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT" + } + Self::REPAIR_ACTION_DISCARD_SNAPSHOT => "REPAIR_ACTION_DISCARD_SNAPSHOT", + Self::REPAIR_ACTION_REVERIFY_ARTIFACT => "REPAIR_ACTION_REVERIFY_ARTIFACT", + Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM => { + "REPAIR_ACTION_RELEASE_ORPHANED_CLAIM" + } + Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE => { + "REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE" + } + Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE => { + "REPAIR_ACTION_RECLAIM_EXPIRED_LEASE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "REPAIR_ACTION_UNSPECIFIED" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_UNSPECIFIED) + } + "REPAIR_ACTION_REBUILD_PROJECTION" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_REBUILD_PROJECTION) + } + "REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION" => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION, + ) + } + "REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT" => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT, + ) + } + "REPAIR_ACTION_DISCARD_SNAPSHOT" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_DISCARD_SNAPSHOT) + } + "REPAIR_ACTION_REVERIFY_ARTIFACT" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_REVERIFY_ARTIFACT) + } + "REPAIR_ACTION_RELEASE_ORPHANED_CLAIM" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM) + } + "REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE" => { + ::core::option::Option::Some( + Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE, + ) + } + "REPAIR_ACTION_RECLAIM_EXPIRED_LEASE" => { + ::core::option::Option::Some(Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::REPAIR_ACTION_UNSPECIFIED, + Self::REPAIR_ACTION_REBUILD_PROJECTION, + Self::REPAIR_ACTION_QUARANTINE_PROJECTION_GENERATION, + Self::REPAIR_ACTION_RESET_PROJECTION_CHECKPOINT, + Self::REPAIR_ACTION_DISCARD_SNAPSHOT, + Self::REPAIR_ACTION_REVERIFY_ARTIFACT, + Self::REPAIR_ACTION_RELEASE_ORPHANED_CLAIM, + Self::REPAIR_ACTION_DISCARD_ORPHANED_DERIVED_STATE, + Self::REPAIR_ACTION_RECLAIM_EXPIRED_LEASE, + ] + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.__view.rs new file mode 100644 index 0000000000..0786b46a5c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.__view.rs @@ -0,0 +1,1504 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/repair_session.proto + +/// RepairSessionRequest applies typed repairs to findings from a specific +/// diagnosis. +/// +/// Three properties make this safe, and each of them closes a failure that +/// operator tooling reaches for eventually. +/// +/// It is targeted. There is no "repair everything" shape. A caller names exact +/// findings and the exact action for each, because a bulk repair is a repair +/// whose blast radius nobody reviewed. +/// +/// It is provenanced. `diagnosis_id` binds every mutation to the report that +/// justified it, so an audit can answer what the operator was looking at. +/// +/// It re-verifies. The server re-runs each finding's check before acting on it. +/// The interval between running a doctor and running a repair is where state +/// changes, and a repair that trusts a report from ten minutes ago will happily +/// discard a projection that already rebuilt itself. +#[derive(Clone, Debug, Default)] +pub struct RepairSessionRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The diagnosis whose findings are being acted on. Findings from a different + /// diagnosis are refused rather than looked up, so a repair cannot be + /// assembled from ids an operator collected by hand. + /// + /// Field 2: `diagnosis_id` + pub diagnosis_id: &'a str, + /// Field 3: `mode` + pub mode: ::buffa::EnumValue, + /// Field 4: `targets` + pub targets: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::RepairTargetView<'a>, + >, + /// Why the operator is doing this, for the audit record. Required, and + /// required to be non-empty: a repair with no stated reason is the one that + /// will need explaining later. + /// + /// Field 5: `operator_reason` + pub operator_reason: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RepairSessionRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `diagnosis_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_diagnosis_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `mode` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_mode(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `operator_reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operator_reason(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RepairSessionRequestView<'a> { + type Owned = super::super::RepairSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.diagnosis_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.mode = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operator_reason = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::RepairTargetView, + >(), + )?; + view.targets + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RepairSessionRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RepairSessionRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RepairSessionRequest { + session_id: self.session_id.to_string(), + diagnosis_id: self.diagnosis_id.to_string(), + mode: self.mode, + targets: self + .targets + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + operator_reason: self.operator_reason.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RepairSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.diagnosis_id) as u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operator_reason) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.diagnosis_id, buf); + ::buffa::types::put_int32_field(3u32, self.mode.to_i32(), buf); + for v in &self.targets { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.operator_reason, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RepairSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("diagnosisId", self.diagnosis_id)?; + } + { + __map.serialize_entry("mode", &self.mode)?; + } + if !self.targets.is_empty() { + __map.serialize_entry("targets", &*self.targets)?; + } + { + __map.serialize_entry("operatorReason", self.operator_reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RepairSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest"; +} +::buffa::impl_default_view_instance!(RepairSessionRequestView); +::buffa::impl_view_reborrow!(RepairSessionRequestView); +/** Self-contained, `'static` owned view of a `RepairSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`RepairSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RepairSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RepairSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl RepairSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RepairSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RepairSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RepairSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RepairSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The diagnosis whose findings are being acted on. Findings from a different + /// diagnosis are refused rather than looked up, so a repair cannot be + /// assembled from ids an operator collected by hand. + /// + /// Field 2: `diagnosis_id` + #[must_use] + pub fn diagnosis_id(&self) -> &'_ str { + self.0.reborrow().diagnosis_id + } + /// Field 3: `mode` + #[must_use] + pub fn mode(&self) -> ::buffa::EnumValue { + self.0.reborrow().mode + } + /// Field 4: `targets` + #[must_use] + pub fn targets( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::RepairTargetView<'_>> { + &self.0.reborrow().targets + } + /// Why the operator is doing this, for the audit record. Required, and + /// required to be non-empty: a repair with no stated reason is the one that + /// will need explaining later. + /// + /// Field 5: `operator_reason` + #[must_use] + pub fn operator_reason(&self) -> &'_ str { + self.0.reborrow().operator_reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RepairSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RepairSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RepairSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RepairSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RepairSessionRequest { + type View<'a> = RepairSessionRequestView<'a>; + type ViewHandle = RepairSessionRequestOwnedView; +} +impl ::serde::Serialize for RepairSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RepairTarget is one finding and the action to take on it. +#[derive(Clone, Debug, Default)] +pub struct RepairTargetView<'a> { + /// Field 1: `finding_id` + pub finding_id: &'a str, + /// Must be one of the finding's `available_repairs`. An action the doctor did + /// not offer for this finding is refused, so the set of legal repairs is + /// decided by the code that understands the finding rather than by the caller. + /// + /// Field 2: `action` + pub action: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RepairTargetView<'a> { + /**Whether required field `finding_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_finding_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `action` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_action(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RepairTargetView<'a> { + type Owned = super::super::RepairTarget; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.finding_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RepairTarget { + finding_id: self.finding_id.to_string(), + action: self.action, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RepairTargetView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.action.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RepairTargetView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("findingId", self.finding_id)?; + } + { + __map.serialize_entry("action", &self.action)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RepairTargetView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairTarget"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairTarget"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairTarget"; +} +::buffa::impl_default_view_instance!(RepairTargetView); +::buffa::impl_view_reborrow!(RepairTargetView); +/** Self-contained, `'static` owned view of a `RepairTarget` message. + + Wraps [`::buffa::OwnedView`]`<`[`RepairTargetView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RepairTargetView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RepairTargetOwnedView(::buffa::OwnedView>); +impl RepairTargetOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairTargetOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairTargetOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RepairTarget, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairTargetOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RepairTargetView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RepairTargetView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RepairTarget { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `finding_id` + #[must_use] + pub fn finding_id(&self) -> &'_ str { + self.0.reborrow().finding_id + } + /// Must be one of the finding's `available_repairs`. An action the doctor did + /// not offer for this finding is refused, so the set of legal repairs is + /// decided by the code that understands the finding rather than by the caller. + /// + /// Field 2: `action` + #[must_use] + pub fn action(&self) -> ::buffa::EnumValue { + self.0.reborrow().action + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RepairTargetOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RepairTargetOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RepairTargetOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RepairTargetOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RepairTarget { + type View<'a> = RepairTargetView<'a>; + type ViewHandle = RepairTargetOwnedView; +} +impl ::serde::Serialize for RepairTargetOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RepairSessionResponse is what happened, or what would have. +#[derive(Clone, Debug, Default)] +pub struct RepairSessionResponseView<'a> { + /// Echoes the mode that ran. A dry run and an apply must never be + /// distinguishable only by what the caller believes it sent. + /// + /// Field 1: `mode` + pub mode: ::buffa::EnumValue, + /// Field 2: `results` + pub results: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::RepairResultView<'a>, + >, + /// Field 3: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RepairSessionResponseView<'a> { + /**Whether required field `mode` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_mode(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for RepairSessionResponseView<'a> { + type Owned = super::super::RepairSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.mode = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::RepairResultView, + >(), + )?; + view.results + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RepairSessionResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RepairSessionResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RepairSessionResponse { + mode: self.mode, + results: self + .results + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RepairSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.results { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.mode.to_i32(), buf); + for v in &self.results { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RepairSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("mode", &self.mode)?; + } + if !self.results.is_empty() { + __map.serialize_entry("results", &*self.results)?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RepairSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse"; +} +::buffa::impl_default_view_instance!(RepairSessionResponseView); +::buffa::impl_view_reborrow!(RepairSessionResponseView); +/** Self-contained, `'static` owned view of a `RepairSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`RepairSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RepairSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RepairSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl RepairSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RepairSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RepairSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RepairSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RepairSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Echoes the mode that ran. A dry run and an apply must never be + /// distinguishable only by what the caller believes it sent. + /// + /// Field 1: `mode` + #[must_use] + pub fn mode(&self) -> ::buffa::EnumValue { + self.0.reborrow().mode + } + /// Field 2: `results` + #[must_use] + pub fn results( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::RepairResultView<'_>> { + &self.0.reborrow().results + } + /// Field 3: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RepairSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RepairSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RepairSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RepairSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RepairSessionResponse { + type View<'a> = RepairSessionResponseView<'a>; + type ViewHandle = RepairSessionResponseOwnedView; +} +impl ::serde::Serialize for RepairSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RepairResult is the outcome for one target. +#[derive(Clone, Debug, Default)] +pub struct RepairResultView<'a> { + /// Field 1: `finding_id` + pub finding_id: &'a str, + /// Field 2: `action` + pub action: ::buffa::EnumValue, + /// Field 3: `status` + pub status: ::buffa::EnumValue, + /// What the action touched, or would touch: projection generations, snapshot + /// ids, claim ids. The substance of a dry run, and the audit trail of an + /// apply. + /// + /// Field 4: `affected` + pub affected: ::buffa::RepeatedView<'a, &'a str>, + /// Human-readable detail. Never parsed. + /// + /// Field 5: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RepairResultView<'a> { + /**Whether required field `finding_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_finding_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `action` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_action(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `status` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_status(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RepairResultView<'a> { + type Owned = super::super::RepairResult; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.finding_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::borrow_str(&mut cur)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + view.affected.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RepairResult { + finding_id: self.finding_id.to_string(), + action: self.action, + status: self.status, + affected: self.affected.iter().map(|s| s.to_string()).collect(), + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RepairResultView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.affected { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.action.to_i32(), buf); + ::buffa::types::put_int32_field(3u32, self.status.to_i32(), buf); + for v in &self.affected { + ::buffa::types::put_string_field(4u32, v, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RepairResultView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("findingId", self.finding_id)?; + } + { + __map.serialize_entry("action", &self.action)?; + } + { + __map.serialize_entry("status", &self.status)?; + } + if !self.affected.is_empty() { + __map.serialize_entry("affected", &*self.affected)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RepairResultView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairResult"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairResult"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairResult"; +} +::buffa::impl_default_view_instance!(RepairResultView); +::buffa::impl_view_reborrow!(RepairResultView); +/** Self-contained, `'static` owned view of a `RepairResult` message. + + Wraps [`::buffa::OwnedView`]`<`[`RepairResultView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RepairResultView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RepairResultOwnedView(::buffa::OwnedView>); +impl RepairResultOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairResultOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairResultOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RepairResult, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RepairResultOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RepairResultView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RepairResultView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RepairResult { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `finding_id` + #[must_use] + pub fn finding_id(&self) -> &'_ str { + self.0.reborrow().finding_id + } + /// Field 2: `action` + #[must_use] + pub fn action(&self) -> ::buffa::EnumValue { + self.0.reborrow().action + } + /// Field 3: `status` + #[must_use] + pub fn status(&self) -> ::buffa::EnumValue { + self.0.reborrow().status + } + /// What the action touched, or would touch: projection generations, snapshot + /// ids, claim ids. The substance of a dry run, and the audit trail of an + /// apply. + /// + /// Field 4: `affected` + #[must_use] + pub fn affected(&self) -> &::buffa::RepeatedView<'_, &'_ str> { + &self.0.reborrow().affected + } + /// Human-readable detail. Never parsed. + /// + /// Field 5: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RepairResultOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RepairResultOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RepairResultOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RepairResultOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RepairResult { + type View<'a> = RepairResultView<'a>; + type ViewHandle = RepairResultOwnedView; +} +impl ::serde::Serialize for RepairResultOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.rs new file mode 100644 index 0000000000..505019c9c7 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.doctor.v1alpha1.repair_session.rs @@ -0,0 +1,1125 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/doctor/v1alpha1/repair_session.proto + +/// RepairMode is whether this call is allowed to mutate anything. +/// +/// The numbering is load-bearing. Zero is DRY_RUN, so a caller that forgets the +/// field, decodes an older message, or builds a request programmatically and +/// misses a branch gets a preview rather than a mutation. Every other ordering +/// of these values makes the default destructive, and a default that destroys +/// is a defect no amount of documentation fixes. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RepairMode { + /// Treated as DRY_RUN. Unset is a preview, never an apply. + REPAIR_MODE_UNSPECIFIED = 0i32, + /// Re-verify every target and report what would happen. Mutates nothing. + REPAIR_MODE_DRY_RUN = 1i32, + /// Re-verify every target and apply the ones that still hold. + REPAIR_MODE_APPLY = 2i32, +} +impl RepairMode { + ///Idiomatic alias for [`Self::REPAIR_MODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::REPAIR_MODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::REPAIR_MODE_DRY_RUN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DryRun: Self = Self::REPAIR_MODE_DRY_RUN; + ///Idiomatic alias for [`Self::REPAIR_MODE_APPLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Apply: Self = Self::REPAIR_MODE_APPLY; +} +impl ::core::default::Default for RepairMode { + fn default() -> Self { + Self::REPAIR_MODE_UNSPECIFIED + } +} +impl ::serde::Serialize for RepairMode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RepairMode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RepairMode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(RepairMode)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairMode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RepairMode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::REPAIR_MODE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::REPAIR_MODE_DRY_RUN), + 2i32 => ::core::option::Option::Some(Self::REPAIR_MODE_APPLY), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::REPAIR_MODE_UNSPECIFIED => "REPAIR_MODE_UNSPECIFIED", + Self::REPAIR_MODE_DRY_RUN => "REPAIR_MODE_DRY_RUN", + Self::REPAIR_MODE_APPLY => "REPAIR_MODE_APPLY", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "REPAIR_MODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::REPAIR_MODE_UNSPECIFIED) + } + "REPAIR_MODE_DRY_RUN" => { + ::core::option::Option::Some(Self::REPAIR_MODE_DRY_RUN) + } + "REPAIR_MODE_APPLY" => ::core::option::Option::Some(Self::REPAIR_MODE_APPLY), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::REPAIR_MODE_UNSPECIFIED, + Self::REPAIR_MODE_DRY_RUN, + Self::REPAIR_MODE_APPLY, + ] + } +} +/// RepairResultStatus is per-target, because a repair call is not atomic and +/// pretending otherwise would hide which half of it landed. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RepairResultStatus { + REPAIR_RESULT_STATUS_UNSPECIFIED = 0i32, + /// Dry run: the finding still holds and the action would be taken. + REPAIR_RESULT_STATUS_WOULD_APPLY = 1i32, + /// Apply: the action was taken. + REPAIR_RESULT_STATUS_APPLIED = 2i32, + /// Re-verification found the finding no longer holds. Not an error: the + /// problem resolved itself between diagnosis and repair, and doing nothing is + /// the correct outcome. + REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE = 3i32, + /// The action is not among the finding's available repairs. + REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE = 4i32, + /// The finding still holds and the server declined to act, because applying + /// the action in the current state could destroy something recoverable. An + /// unreadable artifact is the standard case: it is not yet known to be lost, + /// so nothing that treats it as lost may run. + REPAIR_RESULT_STATUS_REFUSED_UNSAFE = 5i32, + /// The action was attempted and failed. Distinct from refused: something may + /// have partially changed, and `affected` says what. + REPAIR_RESULT_STATUS_FAILED = 6i32, +} +impl RepairResultStatus { + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::REPAIR_RESULT_STATUS_UNSPECIFIED; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_WOULD_APPLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const WouldApply: Self = Self::REPAIR_RESULT_STATUS_WOULD_APPLY; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_APPLIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Applied: Self = Self::REPAIR_RESULT_STATUS_APPLIED; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotReproducible: Self = Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ActionNotAvailable: Self = Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const RefusedUnsafe: Self = Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE; + ///Idiomatic alias for [`Self::REPAIR_RESULT_STATUS_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::REPAIR_RESULT_STATUS_FAILED; +} +impl ::core::default::Default for RepairResultStatus { + fn default() -> Self { + Self::REPAIR_RESULT_STATUS_UNSPECIFIED + } +} +impl ::serde::Serialize for RepairResultStatus { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RepairResultStatus { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RepairResultStatus; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(RepairResultStatus) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairResultStatus { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RepairResultStatus { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_WOULD_APPLY), + 2i32 => ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_APPLIED), + 3i32 => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE) + } + 4i32 => { + ::core::option::Option::Some( + Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE, + ) + } + 5i32 => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE) + } + 6i32 => ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_FAILED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::REPAIR_RESULT_STATUS_UNSPECIFIED => "REPAIR_RESULT_STATUS_UNSPECIFIED", + Self::REPAIR_RESULT_STATUS_WOULD_APPLY => "REPAIR_RESULT_STATUS_WOULD_APPLY", + Self::REPAIR_RESULT_STATUS_APPLIED => "REPAIR_RESULT_STATUS_APPLIED", + Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE => { + "REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE" + } + Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE => { + "REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE" + } + Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE => { + "REPAIR_RESULT_STATUS_REFUSED_UNSAFE" + } + Self::REPAIR_RESULT_STATUS_FAILED => "REPAIR_RESULT_STATUS_FAILED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "REPAIR_RESULT_STATUS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_UNSPECIFIED) + } + "REPAIR_RESULT_STATUS_WOULD_APPLY" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_WOULD_APPLY) + } + "REPAIR_RESULT_STATUS_APPLIED" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_APPLIED) + } + "REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE) + } + "REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE" => { + ::core::option::Option::Some( + Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE, + ) + } + "REPAIR_RESULT_STATUS_REFUSED_UNSAFE" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE) + } + "REPAIR_RESULT_STATUS_FAILED" => { + ::core::option::Option::Some(Self::REPAIR_RESULT_STATUS_FAILED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::REPAIR_RESULT_STATUS_UNSPECIFIED, + Self::REPAIR_RESULT_STATUS_WOULD_APPLY, + Self::REPAIR_RESULT_STATUS_APPLIED, + Self::REPAIR_RESULT_STATUS_NOT_REPRODUCIBLE, + Self::REPAIR_RESULT_STATUS_ACTION_NOT_AVAILABLE, + Self::REPAIR_RESULT_STATUS_REFUSED_UNSAFE, + Self::REPAIR_RESULT_STATUS_FAILED, + ] + } +} +/// RepairSessionRequest applies typed repairs to findings from a specific +/// diagnosis. +/// +/// Three properties make this safe, and each of them closes a failure that +/// operator tooling reaches for eventually. +/// +/// It is targeted. There is no "repair everything" shape. A caller names exact +/// findings and the exact action for each, because a bulk repair is a repair +/// whose blast radius nobody reviewed. +/// +/// It is provenanced. `diagnosis_id` binds every mutation to the report that +/// justified it, so an audit can answer what the operator was looking at. +/// +/// It re-verifies. The server re-runs each finding's check before acting on it. +/// The interval between running a doctor and running a repair is where state +/// changes, and a repair that trusts a report from ten minutes ago will happily +/// discard a projection that already rebuilt itself. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RepairSessionRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The diagnosis whose findings are being acted on. Findings from a different + /// diagnosis are refused rather than looked up, so a repair cannot be + /// assembled from ids an operator collected by hand. + /// + /// Field 2: `diagnosis_id` + #[serde( + rename = "diagnosisId", + alias = "diagnosis_id", + with = "::buffa::json_helpers::proto_string" + )] + pub diagnosis_id: ::buffa::alloc::string::String, + /// Field 3: `mode` + #[serde(rename = "mode", with = "::buffa::json_helpers::proto_enum")] + pub mode: ::buffa::EnumValue, + /// Field 4: `targets` + #[serde( + rename = "targets", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub targets: ::buffa::alloc::vec::Vec, + /// Why the operator is doing this, for the audit record. Required, and + /// required to be non-empty: a repair with no stated reason is the one that + /// will need explaining later. + /// + /// Field 5: `operator_reason` + #[serde( + rename = "operatorReason", + alias = "operator_reason", + with = "::buffa::json_helpers::proto_string" + )] + pub operator_reason: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for RepairSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RepairSessionRequest") + .field("session_id", &self.session_id) + .field("diagnosis_id", &self.diagnosis_id) + .field("mode", &self.mode) + .field("targets", &self.targets) + .field("operator_reason", &self.operator_reason) + .finish() + } +} +impl RepairSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest"; +} +::buffa::impl_default_instance!(RepairSessionRequest); +impl ::buffa::MessageName for RepairSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest"; +} +impl ::buffa::Message for RepairSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.diagnosis_id) as u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operator_reason) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.diagnosis_id, buf); + ::buffa::types::put_int32_field(3u32, self.mode.to_i32(), buf); + for v in &self.targets { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.operator_reason, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.diagnosis_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.mode = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.targets.push(elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operator_reason, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.diagnosis_id.clear(); + self.mode = ::buffa::EnumValue::from(0); + self.targets.clear(); + self.operator_reason.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPAIR_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RepairTarget is one finding and the action to take on it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RepairTarget { + /// Field 1: `finding_id` + #[serde( + rename = "findingId", + alias = "finding_id", + with = "::buffa::json_helpers::proto_string" + )] + pub finding_id: ::buffa::alloc::string::String, + /// Must be one of the finding's `available_repairs`. An action the doctor did + /// not offer for this finding is refused, so the set of legal repairs is + /// decided by the code that understands the finding rather than by the caller. + /// + /// Field 2: `action` + #[serde(rename = "action", with = "::buffa::json_helpers::proto_enum")] + pub action: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for RepairTarget { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RepairTarget") + .field("finding_id", &self.finding_id) + .field("action", &self.action) + .finish() + } +} +impl RepairTarget { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairTarget"; +} +::buffa::impl_default_instance!(RepairTarget); +impl ::buffa::MessageName for RepairTarget { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairTarget"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairTarget"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairTarget"; +} +impl ::buffa::Message for RepairTarget { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.action.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.finding_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.finding_id.clear(); + self.action = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairTarget { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPAIR_TARGET_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairTarget", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RepairSessionResponse is what happened, or what would have. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RepairSessionResponse { + /// Echoes the mode that ran. A dry run and an apply must never be + /// distinguishable only by what the caller believes it sent. + /// + /// Field 1: `mode` + #[serde(rename = "mode", with = "::buffa::json_helpers::proto_enum")] + pub mode: ::buffa::EnumValue, + /// Field 2: `results` + #[serde( + rename = "results", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub results: ::buffa::alloc::vec::Vec, + /// Field 3: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for RepairSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RepairSessionResponse") + .field("mode", &self.mode) + .field("results", &self.results) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl RepairSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse"; +} +::buffa::impl_default_instance!(RepairSessionResponse); +impl ::buffa::MessageName for RepairSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse"; +} +impl ::buffa::Message for RepairSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.results { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.mode.to_i32(), buf); + for v in &self.results { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.mode = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.results.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.mode = ::buffa::EnumValue::from(0); + self.results.clear(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPAIR_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RepairResult is the outcome for one target. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RepairResult { + /// Field 1: `finding_id` + #[serde( + rename = "findingId", + alias = "finding_id", + with = "::buffa::json_helpers::proto_string" + )] + pub finding_id: ::buffa::alloc::string::String, + /// Field 2: `action` + #[serde(rename = "action", with = "::buffa::json_helpers::proto_enum")] + pub action: ::buffa::EnumValue, + /// Field 3: `status` + #[serde(rename = "status", with = "::buffa::json_helpers::proto_enum")] + pub status: ::buffa::EnumValue, + /// What the action touched, or would touch: projection generations, snapshot + /// ids, claim ids. The substance of a dry run, and the audit trail of an + /// apply. + /// + /// Field 4: `affected` + #[serde( + rename = "affected", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub affected: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Human-readable detail. Never parsed. + /// + /// Field 5: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for RepairResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RepairResult") + .field("finding_id", &self.finding_id) + .field("action", &self.action) + .field("status", &self.status) + .field("affected", &self.affected) + .field("detail", &self.detail) + .finish() + } +} +impl RepairResult { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairResult"; +} +impl RepairResult { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RepairResult); +impl ::buffa::MessageName for RepairResult { + const PACKAGE: &'static str = "trogonai.session.sessions.doctor.v1alpha1"; + const NAME: &'static str = "RepairResult"; + const FULL_NAME: &'static str = "trogonai.session.sessions.doctor.v1alpha1.RepairResult"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairResult"; +} +impl ::buffa::Message for RepairResult { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.finding_id) as u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + for v in &self.affected { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.finding_id, buf); + ::buffa::types::put_int32_field(2u32, self.action.to_i32(), buf); + ::buffa::types::put_int32_field(3u32, self.status.to_i32(), buf); + for v in &self.affected { + ::buffa::types::put_string_field(4u32, v, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.finding_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + self.affected.push(__elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.finding_id.clear(); + self.action = ::buffa::EnumValue::from(0); + self.status = ::buffa::EnumValue::from(0); + self.affected.clear(); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RepairResult { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPAIR_RESULT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.doctor.v1alpha1.RepairResult", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.__view.rs new file mode 100644 index 0000000000..88fe5ec1de --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.__view.rs @@ -0,0 +1,329 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/maintenance_error.proto + +/// MaintenanceError is the typed failure payload for the migration and salvage +/// surface. +/// +/// Kept separate from QueryError and DoctorError on the same reasoning each of +/// those applies: these are operator operations that rewrite or duplicate +/// durable state, and their failure vocabulary should be free to grow without +/// that growth being a client-visible or diagnostic-visible change. +/// +/// An operation that ran and could not be classified is not an error. It is a +/// successful call reporting MAINTENANCE_STATE_INDETERMINATE, because it has a +/// durable record and a defined next step, and turning it into an error would +/// discard both. +#[derive(Clone, Debug, Default)] +pub struct MaintenanceErrorView<'a> { + /// Field 1: `code` + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + pub message: &'a str, + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + pub field_path: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MaintenanceErrorView<'a> { + /**Whether required field `code` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_code(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for MaintenanceErrorView<'a> { + type Owned = super::super::MaintenanceError; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.code = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.field_path = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MaintenanceError { + code: self.code, + message: self.message.to_string(), + field_path: self.field_path.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MaintenanceErrorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let Some(ref v) = self.field_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let Some(ref v) = self.field_path { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MaintenanceErrorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("code", &self.code)?; + } + { + __map.serialize_entry("message", self.message)?; + } + if let ::core::option::Option::Some(__v) = self.field_path { + __map.serialize_entry("fieldPath", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MaintenanceErrorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MaintenanceError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError"; +} +::buffa::impl_default_view_instance!(MaintenanceErrorView); +::buffa::impl_view_reborrow!(MaintenanceErrorView); +/** Self-contained, `'static` owned view of a `MaintenanceError` message. + + Wraps [`::buffa::OwnedView`]`<`[`MaintenanceErrorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MaintenanceErrorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MaintenanceErrorOwnedView(::buffa::OwnedView>); +impl MaintenanceErrorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MaintenanceErrorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MaintenanceErrorOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MaintenanceError, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MaintenanceErrorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MaintenanceErrorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MaintenanceErrorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MaintenanceError { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `code` + #[must_use] + pub fn code(&self) -> ::buffa::EnumValue { + self.0.reborrow().code + } + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + #[must_use] + pub fn message(&self) -> &'_ str { + self.0.reborrow().message + } + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + #[must_use] + pub fn field_path(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().field_path + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MaintenanceErrorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MaintenanceErrorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MaintenanceErrorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MaintenanceErrorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MaintenanceError { + type View<'a> = MaintenanceErrorView<'a>; + type ViewHandle = MaintenanceErrorOwnedView; +} +impl ::serde::Serialize for MaintenanceErrorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.rs new file mode 100644 index 0000000000..33df50e59f --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.rs @@ -0,0 +1,461 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/maintenance_error.proto + +/// MaintenanceErrorCode is why an operation could not be attempted. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum MaintenanceErrorCode { + MAINTENANCE_ERROR_CODE_UNSPECIFIED = 0i32, + MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND = 1i32, + MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT = 2i32, + /// Reconciliation was asked about an identity with no recorded intent. Distinct + /// from an indeterminate outcome: there is no operation to reconcile, so there + /// is nothing to report a state for. + MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND = 3i32, + /// The request's parameters do not reproduce the identity it names. Refused + /// rather than treated as a new operation, because the caller believes it is + /// retrying something it is not. + MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH = 4i32, + /// Another maintenance operation holds this session. Two concurrent migrations + /// of one session both write a target, and only one can be right. + MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS = 5i32, + /// Planning and committing are authorized separately: the right to see what a + /// migration would do does not carry the right to run it. + MAINTENANCE_ERROR_CODE_PERMISSION_DENIED = 6i32, + MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED = 7i32, + MAINTENANCE_ERROR_CODE_INTERNAL = 8i32, +} +impl MaintenanceErrorCode { + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SessionNotFound: Self = Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InvalidArgument: Self = Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IntentNotFound: Self = Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IdentityMismatch: Self = Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationInProgress: Self = Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PermissionDenied: Self = Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ResourceExhausted: Self = Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED; + ///Idiomatic alias for [`Self::MAINTENANCE_ERROR_CODE_INTERNAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Internal: Self = Self::MAINTENANCE_ERROR_CODE_INTERNAL; +} +impl ::core::default::Default for MaintenanceErrorCode { + fn default() -> Self { + Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED + } +} +impl ::serde::Serialize for MaintenanceErrorCode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for MaintenanceErrorCode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = MaintenanceErrorCode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(MaintenanceErrorCode) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for MaintenanceErrorCode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for MaintenanceErrorCode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some(Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED) + } + 1i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND, + ) + } + 2i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH, + ) + } + 5i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS, + ) + } + 6i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED, + ) + } + 7i32 => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED, + ) + } + 8i32 => ::core::option::Option::Some(Self::MAINTENANCE_ERROR_CODE_INTERNAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED => { + "MAINTENANCE_ERROR_CODE_UNSPECIFIED" + } + Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND => { + "MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND" + } + Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT => { + "MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT" + } + Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND => { + "MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND" + } + Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH => { + "MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH" + } + Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS => { + "MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS" + } + Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED => { + "MAINTENANCE_ERROR_CODE_PERMISSION_DENIED" + } + Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED => { + "MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED" + } + Self::MAINTENANCE_ERROR_CODE_INTERNAL => "MAINTENANCE_ERROR_CODE_INTERNAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "MAINTENANCE_ERROR_CODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED) + } + "MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND, + ) + } + "MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT, + ) + } + "MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND, + ) + } + "MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH, + ) + } + "MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS, + ) + } + "MAINTENANCE_ERROR_CODE_PERMISSION_DENIED" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED, + ) + } + "MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED" => { + ::core::option::Option::Some( + Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED, + ) + } + "MAINTENANCE_ERROR_CODE_INTERNAL" => { + ::core::option::Option::Some(Self::MAINTENANCE_ERROR_CODE_INTERNAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::MAINTENANCE_ERROR_CODE_UNSPECIFIED, + Self::MAINTENANCE_ERROR_CODE_SESSION_NOT_FOUND, + Self::MAINTENANCE_ERROR_CODE_INVALID_ARGUMENT, + Self::MAINTENANCE_ERROR_CODE_INTENT_NOT_FOUND, + Self::MAINTENANCE_ERROR_CODE_IDENTITY_MISMATCH, + Self::MAINTENANCE_ERROR_CODE_OPERATION_IN_PROGRESS, + Self::MAINTENANCE_ERROR_CODE_PERMISSION_DENIED, + Self::MAINTENANCE_ERROR_CODE_RESOURCE_EXHAUSTED, + Self::MAINTENANCE_ERROR_CODE_INTERNAL, + ] + } +} +/// MaintenanceError is the typed failure payload for the migration and salvage +/// surface. +/// +/// Kept separate from QueryError and DoctorError on the same reasoning each of +/// those applies: these are operator operations that rewrite or duplicate +/// durable state, and their failure vocabulary should be free to grow without +/// that growth being a client-visible or diagnostic-visible change. +/// +/// An operation that ran and could not be classified is not an error. It is a +/// successful call reporting MAINTENANCE_STATE_INDETERMINATE, because it has a +/// durable record and a defined next step, and turning it into an error would +/// discard both. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MaintenanceError { + /// Field 1: `code` + #[serde(rename = "code", with = "::buffa::json_helpers::proto_enum")] + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `message` + #[serde(rename = "message", with = "::buffa::json_helpers::proto_string")] + pub message: ::buffa::alloc::string::String, + /// Dotted path into the request for INVALID_ARGUMENT. + /// + /// Field 3: `field_path` + #[serde( + rename = "fieldPath", + alias = "field_path", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub field_path: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for MaintenanceError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MaintenanceError") + .field("code", &self.code) + .field("message", &self.message) + .field("field_path", &self.field_path) + .finish() + } +} +impl MaintenanceError { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError"; +} +impl MaintenanceError { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::field_path`] to `Some(value)`, consuming and returning `self`. + pub fn with_field_path( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.field_path = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(MaintenanceError); +impl ::buffa::MessageName for MaintenanceError { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MaintenanceError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError"; +} +impl ::buffa::Message for MaintenanceError { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let Some(ref v) = self.field_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let Some(ref v) = self.field_path { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.code = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .field_path + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.code = ::buffa::EnumValue::from(0); + self.message.clear(); + self.field_path = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for MaintenanceError { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MAINTENANCE_ERROR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MaintenanceError", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.__view.rs new file mode 100644 index 0000000000..42674aa993 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.__view.rs @@ -0,0 +1,1383 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/migrate_session.proto + +/// MigrateSession rewrites one session's stored events under a newer storage +/// schema, keeping the session's identity and its ordinals. +/// +/// Ordering of effects is fixed and not an implementation detail: record the +/// intent, stage the target, commit, validate. A process that dies at any point +/// leaves state that ReconcileMigration can classify, because the intent was +/// written before anything else was. +#[derive(Clone, Debug, Default)] +pub struct MigrateSessionRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `target_schema_version` + pub target_schema_version: u32, + /// Field 3: `implementation_version` + pub implementation_version: &'a str, + /// Field 4: `actor` + pub actor: &'a str, + /// Field 5: `reason` + pub reason: &'a str, + /// Unset is PLAN_ONLY. The zero value is the one that writes nothing, so a + /// caller that forgets the field gets a plan instead of a rewrite. + /// + /// Field 6: `mode` + pub mode: ::core::option::Option<::buffa::EnumValue>, + /// The source boundary the caller already observed. A fleet orchestrator that + /// read the source sets this, and the migration refuses if the source has + /// moved since. Unset means the migration observes and pins the boundary + /// itself, which is correct for a single session and racy for a fleet run that + /// decided what to migrate minutes ago. + /// + /// Field 7: `expected_source` + pub expected_source: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// Field 8: `limits` + pub limits: ::buffa::MessageFieldView< + super::super::__buffa::view::MigrationLimitsView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MigrateSessionRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `target_schema_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_target_schema_version(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `implementation_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_implementation_version(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `actor` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_actor(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for MigrateSessionRequestView<'a> { + type Owned = super::super::MigrateSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.target_schema_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.implementation_version = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.actor = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.mode = Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(&mut cur)?), + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.expected_source.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.expected_source = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.limits.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.limits = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::MigrateSessionRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::MigrateSessionRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrateSessionRequest { + session_id: self.session_id.to_string(), + target_schema_version: self.target_schema_version, + implementation_version: self.implementation_version.to_string(), + actor: self.actor.to_string(), + reason: self.reason.to_string(), + mode: self.mode, + expected_source: match self.expected_source.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + limits: match self.limits.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::MigrationLimits, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrateSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.target_schema_version) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.implementation_version) + as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if let Some(ref v) = self.mode { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if self.expected_source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.limits.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.limits.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint32_field(2u32, self.target_schema_version, buf); + ::buffa::types::put_string_field(3u32, &self.implementation_version, buf); + ::buffa::types::put_string_field(4u32, &self.actor, buf); + ::buffa::types::put_string_field(5u32, &self.reason, buf); + if let Some(ref v) = self.mode { + ::buffa::types::put_int32_field(6u32, v.to_i32(), buf); + } + if self.expected_source.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_source.write_to(__cache, buf); + } + if self.limits.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.limits.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrateSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map + .serialize_entry( + "targetSchemaVersion", + &::buffa::json_helpers::ProtoJson(&self.target_schema_version), + )?; + } + { + __map.serialize_entry("implementationVersion", self.implementation_version)?; + } + { + __map.serialize_entry("actor", self.actor)?; + } + { + __map.serialize_entry("reason", self.reason)?; + } + if let ::core::option::Option::Some(ref __v) = self.mode { + __map.serialize_entry("mode", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.expected_source.as_option() { + __map.serialize_entry("expectedSource", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.limits.as_option() { + __map.serialize_entry("limits", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrateSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrateSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest"; +} +::buffa::impl_default_view_instance!(MigrateSessionRequestView); +::buffa::impl_view_reborrow!(MigrateSessionRequestView); +/** Self-contained, `'static` owned view of a `MigrateSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrateSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrateSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrateSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl MigrateSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrateSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrateSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrateSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrateSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `target_schema_version` + #[must_use] + pub fn target_schema_version(&self) -> u32 { + self.0.reborrow().target_schema_version + } + /// Field 3: `implementation_version` + #[must_use] + pub fn implementation_version(&self) -> &'_ str { + self.0.reborrow().implementation_version + } + /// Field 4: `actor` + #[must_use] + pub fn actor(&self) -> &'_ str { + self.0.reborrow().actor + } + /// Field 5: `reason` + #[must_use] + pub fn reason(&self) -> &'_ str { + self.0.reborrow().reason + } + /// Unset is PLAN_ONLY. The zero value is the one that writes nothing, so a + /// caller that forgets the field gets a plan instead of a rewrite. + /// + /// Field 6: `mode` + #[must_use] + pub fn mode( + &self, + ) -> ::core::option::Option<::buffa::EnumValue> { + self.0.reborrow().mode + } + /// The source boundary the caller already observed. A fleet orchestrator that + /// read the source sets this, and the migration refuses if the source has + /// moved since. Unset means the migration observes and pins the boundary + /// itself, which is correct for a single session and racy for a fleet run that + /// decided what to migrate minutes ago. + /// + /// Field 7: `expected_source` + #[must_use] + pub fn expected_source( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().expected_source + } + /// Field 8: `limits` + #[must_use] + pub fn limits( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::MigrationLimitsView<'_>, + > { + &self.0.reborrow().limits + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrateSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrateSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrateSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrateSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrateSessionRequest { + type View<'a> = MigrateSessionRequestView<'a>; + type ViewHandle = MigrateSessionRequestOwnedView; +} +impl ::serde::Serialize for MigrateSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// MigrationLimits bounds one call. A migration reads and rewrites an entire +/// stream, so an unbounded one on a large session is an outage. +#[derive(Clone, Debug, Default)] +pub struct MigrationLimitsView<'a> { + /// Field 1: `max_source_events` + pub max_source_events: ::core::option::Option, + /// Field 2: `max_source_bytes` + pub max_source_bytes: ::core::option::Option, + /// Field 3: `max_duration` + pub max_duration: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, +} +impl<'a> ::buffa::MessageView<'a> for MigrationLimitsView<'a> { + type Owned = super::super::MigrationLimits; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_source_events = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_source_bytes = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.max_duration.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.max_duration = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrationLimits { + max_source_events: self.max_source_events, + max_source_bytes: self.max_source_bytes, + max_duration: match self.max_duration.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrationLimitsView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_source_events { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_source_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_source_events { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_source_bytes { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrationLimitsView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(__v) = self.max_source_events { + __map + .serialize_entry( + "maxSourceEvents", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.max_source_bytes { + __map + .serialize_entry( + "maxSourceBytes", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.max_duration.as_option() { + __map.serialize_entry("maxDuration", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrationLimitsView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationLimits"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits"; +} +::buffa::impl_default_view_instance!(MigrationLimitsView); +::buffa::impl_view_reborrow!(MigrationLimitsView); +/** Self-contained, `'static` owned view of a `MigrationLimits` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrationLimitsView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrationLimitsView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrationLimitsOwnedView(::buffa::OwnedView>); +impl MigrationLimitsOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationLimitsOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationLimitsOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrationLimits, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationLimitsOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrationLimitsView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrationLimitsView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrationLimits { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `max_source_events` + #[must_use] + pub fn max_source_events(&self) -> ::core::option::Option { + self.0.reborrow().max_source_events + } + /// Field 2: `max_source_bytes` + #[must_use] + pub fn max_source_bytes(&self) -> ::core::option::Option { + self.0.reborrow().max_source_bytes + } + /// Field 3: `max_duration` + #[must_use] + pub fn max_duration( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().max_duration + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrationLimitsOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrationLimitsOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrationLimitsOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrationLimitsOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrationLimits { + type View<'a> = MigrationLimitsView<'a>; + type ViewHandle = MigrationLimitsOwnedView; +} +impl ::serde::Serialize for MigrationLimitsOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct MigrateSessionResponseView<'a> { + /// Field 1: `result` + pub result: ::buffa::EnumValue, + /// Always present, including on refusal: the record is what a later + /// reconciliation is run against, so a caller that cannot store it cannot + /// reconcile. + /// + /// Field 2: `record` + pub record: ::buffa::MessageFieldView< + super::super::__buffa::view::MigrationRecordView<'a>, + >, + /// Set only for MIGRATION_RESULT_NOT_ADMISSIBLE. + /// + /// Field 3: `not_admissible` + pub not_admissible: ::buffa::MessageFieldView< + super::super::__buffa::view::AdmissibilityDetailView<'a>, + >, + /// Field 4: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MigrateSessionResponseView<'a> { + /**Whether required field `result` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_result(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `record` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_record(&self) -> bool { + self.record.is_set() + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for MigrateSessionResponseView<'a> { + type Owned = super::super::MigrateSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.record.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.record = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.not_admissible.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.not_admissible = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::MigrateSessionResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::MigrateSessionResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrateSessionResponse { + result: self.result, + record: match self.record.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::MigrationRecord, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + not_admissible: match self.not_admissible.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::AdmissibilityDetail, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrateSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.not_admissible.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.not_admissible.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + if self.not_admissible.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.not_admissible.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrateSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("result", &self.result)?; + } + { + if let ::core::option::Option::Some(__v) = self.record.as_option() { + __map.serialize_entry("record", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.not_admissible.as_option() { + __map.serialize_entry("notAdmissible", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrateSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrateSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse"; +} +::buffa::impl_default_view_instance!(MigrateSessionResponseView); +::buffa::impl_view_reborrow!(MigrateSessionResponseView); +/** Self-contained, `'static` owned view of a `MigrateSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrateSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrateSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrateSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl MigrateSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrateSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrateSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrateSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrateSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrateSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `result` + #[must_use] + pub fn result(&self) -> ::buffa::EnumValue { + self.0.reborrow().result + } + /// Always present, including on refusal: the record is what a later + /// reconciliation is run against, so a caller that cannot store it cannot + /// reconcile. + /// + /// Field 2: `record` + #[must_use] + pub fn record( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::MigrationRecordView<'_>, + > { + &self.0.reborrow().record + } + /// Set only for MIGRATION_RESULT_NOT_ADMISSIBLE. + /// + /// Field 3: `not_admissible` + #[must_use] + pub fn not_admissible( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::AdmissibilityDetailView<'_>, + > { + &self.0.reborrow().not_admissible + } + /// Field 4: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrateSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrateSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrateSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrateSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrateSessionResponse { + type View<'a> = MigrateSessionResponseView<'a>; + type ViewHandle = MigrateSessionResponseOwnedView; +} +impl ::serde::Serialize for MigrateSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.rs new file mode 100644 index 0000000000..0aefbeb400 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migrate_session.rs @@ -0,0 +1,870 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/migrate_session.proto + +/// MigrationMode is whether this call may write. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum MigrationMode { + MIGRATION_MODE_UNSPECIFIED = 0i32, + /// Validate admissibility, compute the intent, write nothing. + MIGRATION_MODE_PLAN_ONLY = 1i32, + MIGRATION_MODE_COMMIT = 2i32, +} +impl MigrationMode { + ///Idiomatic alias for [`Self::MIGRATION_MODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::MIGRATION_MODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::MIGRATION_MODE_PLAN_ONLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PlanOnly: Self = Self::MIGRATION_MODE_PLAN_ONLY; + ///Idiomatic alias for [`Self::MIGRATION_MODE_COMMIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Commit: Self = Self::MIGRATION_MODE_COMMIT; +} +impl ::core::default::Default for MigrationMode { + fn default() -> Self { + Self::MIGRATION_MODE_UNSPECIFIED + } +} +impl ::serde::Serialize for MigrationMode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for MigrationMode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = MigrationMode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(MigrationMode)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationMode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for MigrationMode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::MIGRATION_MODE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::MIGRATION_MODE_PLAN_ONLY), + 2i32 => ::core::option::Option::Some(Self::MIGRATION_MODE_COMMIT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::MIGRATION_MODE_UNSPECIFIED => "MIGRATION_MODE_UNSPECIFIED", + Self::MIGRATION_MODE_PLAN_ONLY => "MIGRATION_MODE_PLAN_ONLY", + Self::MIGRATION_MODE_COMMIT => "MIGRATION_MODE_COMMIT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "MIGRATION_MODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::MIGRATION_MODE_UNSPECIFIED) + } + "MIGRATION_MODE_PLAN_ONLY" => { + ::core::option::Option::Some(Self::MIGRATION_MODE_PLAN_ONLY) + } + "MIGRATION_MODE_COMMIT" => { + ::core::option::Option::Some(Self::MIGRATION_MODE_COMMIT) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::MIGRATION_MODE_UNSPECIFIED, + Self::MIGRATION_MODE_PLAN_ONLY, + Self::MIGRATION_MODE_COMMIT, + ] + } +} +/// MigrateSession rewrites one session's stored events under a newer storage +/// schema, keeping the session's identity and its ordinals. +/// +/// Ordering of effects is fixed and not an implementation detail: record the +/// intent, stage the target, commit, validate. A process that dies at any point +/// leaves state that ReconcileMigration can classify, because the intent was +/// written before anything else was. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrateSessionRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `target_schema_version` + #[serde( + rename = "targetSchemaVersion", + alias = "target_schema_version", + with = "::buffa::json_helpers::uint32" + )] + pub target_schema_version: u32, + /// Field 3: `implementation_version` + #[serde( + rename = "implementationVersion", + alias = "implementation_version", + with = "::buffa::json_helpers::proto_string" + )] + pub implementation_version: ::buffa::alloc::string::String, + /// Field 4: `actor` + #[serde(rename = "actor", with = "::buffa::json_helpers::proto_string")] + pub actor: ::buffa::alloc::string::String, + /// Field 5: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_string")] + pub reason: ::buffa::alloc::string::String, + /// Unset is PLAN_ONLY. The zero value is the one that writes nothing, so a + /// caller that forgets the field gets a plan instead of a rewrite. + /// + /// Field 6: `mode` + #[serde( + rename = "mode", + with = "::buffa::json_helpers::opt_enum", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub mode: ::core::option::Option<::buffa::EnumValue>, + /// The source boundary the caller already observed. A fleet orchestrator that + /// read the source sets this, and the migration refuses if the source has + /// moved since. Unset means the migration observes and pins the boundary + /// itself, which is correct for a single session and racy for a fleet run that + /// decided what to migrate minutes ago. + /// + /// Field 7: `expected_source` + #[serde( + rename = "expectedSource", + alias = "expected_source", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub expected_source: ::buffa::MessageField< + StreamBoundary, + ::buffa::Inline, + >, + /// Field 8: `limits` + #[serde( + rename = "limits", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub limits: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for MigrateSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrateSessionRequest") + .field("session_id", &self.session_id) + .field("target_schema_version", &self.target_schema_version) + .field("implementation_version", &self.implementation_version) + .field("actor", &self.actor) + .field("reason", &self.reason) + .field("mode", &self.mode) + .field("expected_source", &self.expected_source) + .field("limits", &self.limits) + .finish() + } +} +impl MigrateSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest"; +} +impl MigrateSessionRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::mode`] to `Some(value)`, consuming and returning `self`. + pub fn with_mode( + mut self, + value: impl Into<::buffa::EnumValue>, + ) -> Self { + self.mode = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(MigrateSessionRequest); +impl ::buffa::MessageName for MigrateSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrateSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest"; +} +impl ::buffa::Message for MigrateSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.target_schema_version) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.implementation_version) + as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if let Some(ref v) = self.mode { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if self.expected_source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.limits.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.limits.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint32_field(2u32, self.target_schema_version, buf); + ::buffa::types::put_string_field(3u32, &self.implementation_version, buf); + ::buffa::types::put_string_field(4u32, &self.actor, buf); + ::buffa::types::put_string_field(5u32, &self.reason, buf); + if let Some(ref v) = self.mode { + ::buffa::types::put_int32_field(6u32, v.to_i32(), buf); + } + if self.expected_source.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_source.write_to(__cache, buf); + } + if self.limits.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.limits.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.target_schema_version = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.implementation_version, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.actor, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.reason, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.mode = ::core::option::Option::Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.expected_source.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.limits.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.target_schema_version = 0u32; + self.implementation_version.clear(); + self.actor.clear(); + self.reason.clear(); + self.mode = ::core::option::Option::None; + self.expected_source = ::buffa::MessageField::none(); + self.limits = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrateSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATE_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// MigrationLimits bounds one call. A migration reads and rewrites an entire +/// stream, so an unbounded one on a large session is an outage. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrationLimits { + /// Field 1: `max_source_events` + #[serde( + rename = "maxSourceEvents", + alias = "max_source_events", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_source_events: ::core::option::Option, + /// Field 2: `max_source_bytes` + #[serde( + rename = "maxSourceBytes", + alias = "max_source_bytes", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_source_bytes: ::core::option::Option, + /// Field 3: `max_duration` + #[serde( + rename = "maxDuration", + alias = "max_duration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub max_duration: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for MigrationLimits { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrationLimits") + .field("max_source_events", &self.max_source_events) + .field("max_source_bytes", &self.max_source_bytes) + .field("max_duration", &self.max_duration) + .finish() + } +} +impl MigrationLimits { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits"; +} +impl MigrationLimits { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_source_events`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_source_events(mut self, value: u64) -> Self { + self.max_source_events = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_source_bytes`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_source_bytes(mut self, value: u64) -> Self { + self.max_source_bytes = Some(value); + self + } +} +::buffa::impl_default_instance!(MigrationLimits); +impl ::buffa::MessageName for MigrationLimits { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationLimits"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits"; +} +impl ::buffa::Message for MigrationLimits { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_source_events { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_source_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_source_events { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_source_bytes { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_source_events = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_source_bytes = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.max_duration.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.max_source_events = ::core::option::Option::None; + self.max_source_bytes = ::core::option::Option::None; + self.max_duration = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationLimits { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATION_LIMITS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationLimits", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrateSessionResponse { + /// Field 1: `result` + #[serde(rename = "result", with = "::buffa::json_helpers::proto_enum")] + pub result: ::buffa::EnumValue, + /// Always present, including on refusal: the record is what a later + /// reconciliation is run against, so a caller that cannot store it cannot + /// reconcile. + /// + /// Field 2: `record` + #[serde(rename = "record")] + pub record: ::buffa::MessageField>, + /// Set only for MIGRATION_RESULT_NOT_ADMISSIBLE. + /// + /// Field 3: `not_admissible` + #[serde( + rename = "notAdmissible", + alias = "not_admissible", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub not_admissible: ::buffa::MessageField< + AdmissibilityDetail, + ::buffa::Inline, + >, + /// Field 4: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for MigrateSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrateSessionResponse") + .field("result", &self.result) + .field("record", &self.record) + .field("not_admissible", &self.not_admissible) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl MigrateSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse"; +} +::buffa::impl_default_instance!(MigrateSessionResponse); +impl ::buffa::MessageName for MigrateSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrateSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse"; +} +impl ::buffa::Message for MigrateSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.not_admissible.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.not_admissible.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + if self.not_admissible.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.not_admissible.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.record.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.not_admissible.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.result = ::buffa::EnumValue::from(0); + self.record = ::buffa::MessageField::none(); + self.not_admissible = ::buffa::MessageField::none(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrateSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATE_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrateSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.__view.rs new file mode 100644 index 0000000000..8ac009f2da --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.__view.rs @@ -0,0 +1,1976 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/migration.proto + +/// The durable record of a Session migration. +/// +/// A migration rewrites one session's stored events under a newer storage schema +/// and keeps the session's identity. Two rules make that safe, and both are +/// admissibility requirements rather than best effort: +/// +/// 1. Ordinals are preserved exactly. The target has the same event count as the +/// ```text +/// source, one transformed payload per source position. Inserting or removing +/// an event would renumber every following SessionOrdinal, and ordinals are +/// referenced from outside this stream: fork context boundaries on child +/// sessions, checkpoint evidence, consistency tokens, and page cursors would +/// all silently come to mean something else. +/// ``` +/// 2. The transformation is byte-deterministic. Given the same source bytes and +/// ```text +/// the same implementation_version, it produces the same target bytes. +/// ``` +/// +/// The second rule is what makes a lost commit acknowledgment recoverable: the +/// expected target digest can be written down before the commit, so a later look +/// at the target answers "did my write land" instead of "did some write land." +/// A transformation that cannot reproduce its own output is not a migration. It +/// is a salvage, and it must mint a new identity. +/// +/// MigrationIdentity is the retry identity of a migration. +/// +/// Two attempts sharing this tuple are the same migration and the second is +/// idempotent. Two attempts differing anywhere in it are different migrations, +/// and treating the second as a retry of the first is how a session gets +/// migrated twice. +#[derive(Clone, Debug, Default)] +pub struct MigrationIdentityView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Digest of the source cut. Part of identity because a migration of different + /// source content is a different migration even under the same version pair. + /// + /// Field 2: `source_digest` + pub source_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::ContentDigestView<'a>, + >, + /// Pins the transformation, including its encoder. Byte-determinism is scoped + /// to this value: a new encoder is a new implementation_version, because the + /// output bytes are part of what it promises. + /// + /// Field 3: `implementation_version` + pub implementation_version: &'a str, + /// Field 4: `source_schema_version` + pub source_schema_version: u32, + /// Field 5: `target_schema_version` + pub target_schema_version: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MigrationIdentityView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `source_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_digest(&self) -> bool { + self.source_digest.is_set() + } + /**Whether required field `implementation_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_implementation_version(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `source_schema_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_schema_version(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `target_schema_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_target_schema_version(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for MigrationIdentityView<'a> { + type Owned = super::super::MigrationIdentity; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.implementation_version = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source_schema_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.target_schema_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrationIdentity { + session_id: self.session_id.to_string(), + source_digest: match self.source_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContentDigest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + implementation_version: self.implementation_version.to_string(), + source_schema_version: self.source_schema_version, + target_schema_version: self.target_schema_version, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrationIdentityView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.implementation_version) + as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.source_schema_version) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.target_schema_version) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.implementation_version, buf); + ::buffa::types::put_uint32_field(4u32, self.source_schema_version, buf); + ::buffa::types::put_uint32_field(5u32, self.target_schema_version, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrationIdentityView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.source_digest.as_option() { + __map.serialize_entry("sourceDigest", __v)?; + } + } + { + __map.serialize_entry("implementationVersion", self.implementation_version)?; + } + { + __map + .serialize_entry( + "sourceSchemaVersion", + &::buffa::json_helpers::ProtoJson(&self.source_schema_version), + )?; + } + { + __map + .serialize_entry( + "targetSchemaVersion", + &::buffa::json_helpers::ProtoJson(&self.target_schema_version), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrationIdentityView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationIdentity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity"; +} +::buffa::impl_default_view_instance!(MigrationIdentityView); +::buffa::impl_view_reborrow!(MigrationIdentityView); +/** Self-contained, `'static` owned view of a `MigrationIdentity` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrationIdentityView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrationIdentityView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrationIdentityOwnedView( + ::buffa::OwnedView>, +); +impl MigrationIdentityOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIdentityOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIdentityOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrationIdentity, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIdentityOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrationIdentityView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrationIdentityView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrationIdentity { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Digest of the source cut. Part of identity because a migration of different + /// source content is a different migration even under the same version pair. + /// + /// Field 2: `source_digest` + #[must_use] + pub fn source_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().source_digest + } + /// Pins the transformation, including its encoder. Byte-determinism is scoped + /// to this value: a new encoder is a new implementation_version, because the + /// output bytes are part of what it promises. + /// + /// Field 3: `implementation_version` + #[must_use] + pub fn implementation_version(&self) -> &'_ str { + self.0.reborrow().implementation_version + } + /// Field 4: `source_schema_version` + #[must_use] + pub fn source_schema_version(&self) -> u32 { + self.0.reborrow().source_schema_version + } + /// Field 5: `target_schema_version` + #[must_use] + pub fn target_schema_version(&self) -> u32 { + self.0.reborrow().target_schema_version + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrationIdentityOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrationIdentityOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrationIdentityOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrationIdentityOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrationIdentity { + type View<'a> = MigrationIdentityView<'a>; + type ViewHandle = MigrationIdentityOwnedView; +} +impl ::serde::Serialize for MigrationIdentityOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// MigrationIntent is written durably before any target byte is written. +/// +/// This is the load-bearing record of the whole workflow. Reconciliation is a +/// comparison, and a comparison needs something recorded on the near side of the +/// crash. Without an intent, a process that dies mid-commit leaves a target that +/// nobody can attribute and nobody can safely replace. +#[derive(Clone, Debug, Default)] +pub struct MigrationIntentView<'a> { + /// Field 1: `identity` + pub identity: ::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIdentityView<'a>, + >, + /// Field 2: `source` + pub source: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// The boundary the target will have if the commit lands, computed before the + /// commit is attempted. `expected_target.ordinal` always equals + /// `source.ordinal`; a plan where they differ is not admissible. + /// + /// Field 3: `expected_target` + pub expected_target: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// Field 4: `actor` + pub actor: &'a str, + /// Why this migration was run. A migration is a rewrite of durable history, + /// and an unattributed rewrite is not auditable. + /// + /// Field 5: `reason` + pub reason: &'a str, + /// Field 6: `planned_at` + pub planned_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MigrationIntentView<'a> { + /**Whether required field `identity` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_identity(&self) -> bool { + self.identity.is_set() + } + /**Whether required field `source` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source(&self) -> bool { + self.source.is_set() + } + /**Whether required field `expected_target` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_expected_target(&self) -> bool { + self.expected_target.is_set() + } + /**Whether required field `actor` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_actor(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `planned_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_planned_at(&self) -> bool { + self.planned_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for MigrationIntentView<'a> { + type Owned = super::super::MigrationIntent; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.identity.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.identity = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.expected_target.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.expected_target = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.actor = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.planned_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.planned_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrationIntent { + identity: match self.identity.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::MigrationIdentity, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source: match self.source.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + expected_target: match self.expected_target.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + actor: self.actor.to_string(), + reason: self.reason.to_string(), + planned_at: match self.planned_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrationIntentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.expected_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if self.planned_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.planned_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + if self.source.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source.write_to(__cache, buf); + } + if self.expected_target.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_target.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.actor, buf); + ::buffa::types::put_string_field(5u32, &self.reason, buf); + if self.planned_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.planned_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrationIntentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.identity.as_option() { + __map.serialize_entry("identity", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.source.as_option() { + __map.serialize_entry("source", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.expected_target.as_option() { + __map.serialize_entry("expectedTarget", __v)?; + } + } + { + __map.serialize_entry("actor", self.actor)?; + } + { + __map.serialize_entry("reason", self.reason)?; + } + { + if let ::core::option::Option::Some(__v) = self.planned_at.as_option() { + __map.serialize_entry("plannedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrationIntentView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent"; +} +::buffa::impl_default_view_instance!(MigrationIntentView); +::buffa::impl_view_reborrow!(MigrationIntentView); +/** Self-contained, `'static` owned view of a `MigrationIntent` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrationIntentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrationIntentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrationIntentOwnedView(::buffa::OwnedView>); +impl MigrationIntentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIntentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIntentOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrationIntent, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationIntentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrationIntentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrationIntentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrationIntent { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `identity` + #[must_use] + pub fn identity( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIdentityView<'_>, + > { + &self.0.reborrow().identity + } + /// Field 2: `source` + #[must_use] + pub fn source( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().source + } + /// The boundary the target will have if the commit lands, computed before the + /// commit is attempted. `expected_target.ordinal` always equals + /// `source.ordinal`; a plan where they differ is not admissible. + /// + /// Field 3: `expected_target` + #[must_use] + pub fn expected_target( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().expected_target + } + /// Field 4: `actor` + #[must_use] + pub fn actor(&self) -> &'_ str { + self.0.reborrow().actor + } + /// Why this migration was run. A migration is a rewrite of durable history, + /// and an unattributed rewrite is not auditable. + /// + /// Field 5: `reason` + #[must_use] + pub fn reason(&self) -> &'_ str { + self.0.reborrow().reason + } + /// Field 6: `planned_at` + #[must_use] + pub fn planned_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().planned_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrationIntentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrationIntentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrationIntentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrationIntentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrationIntent { + type View<'a> = MigrationIntentView<'a>; + type ViewHandle = MigrationIntentOwnedView; +} +impl ::serde::Serialize for MigrationIntentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// MigrationRecord is the intent plus everything learned since. +#[derive(Clone, Debug, Default)] +pub struct MigrationRecordView<'a> { + /// Field 1: `intent` + pub intent: ::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIntentView<'a>, + >, + /// Field 2: `state` + pub state: ::buffa::EnumValue, + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + pub indeterminate: ::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'a>, + >, + /// The target as actually observed. Unset before any commit was attempted, and + /// unset after a reconciliation that found no target. + /// + /// Field 4: `observed_target` + pub observed_target: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// Attempts made under this identity. A rising count against an unchanged + /// state is the signal that a retry loop is not converging. + /// + /// Field 5: `attempt_count` + pub attempt_count: u32, + /// Field 6: `updated_at` + pub updated_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MigrationRecordView<'a> { + /**Whether required field `intent` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_intent(&self) -> bool { + self.intent.is_set() + } + /**Whether required field `state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_state(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `attempt_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_attempt_count(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `updated_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_updated_at(&self) -> bool { + self.updated_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for MigrationRecordView<'a> { + type Owned = super::super::MigrationRecord; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.intent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.intent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.indeterminate.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.indeterminate = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_target.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_target = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.attempt_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.updated_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.updated_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MigrationRecord { + intent: match self.intent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::MigrationIntent, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + state: self.state, + indeterminate: match self.indeterminate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::IndeterminateDetail, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_target: match self.observed_target.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + attempt_count: self.attempt_count, + updated_at: match self.updated_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MigrationRecordView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.updated_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.updated_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.intent.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intent.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.state.to_i32(), buf); + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.observed_target.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_target.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.attempt_count, buf); + if self.updated_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.updated_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MigrationRecordView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.intent.as_option() { + __map.serialize_entry("intent", __v)?; + } + } + { + __map.serialize_entry("state", &self.state)?; + } + { + if let ::core::option::Option::Some(__v) = self.indeterminate.as_option() { + __map.serialize_entry("indeterminate", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_target.as_option() { + __map.serialize_entry("observedTarget", __v)?; + } + } + { + __map + .serialize_entry( + "attemptCount", + &::buffa::json_helpers::ProtoJson(&self.attempt_count), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.updated_at.as_option() { + __map.serialize_entry("updatedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MigrationRecordView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord"; +} +::buffa::impl_default_view_instance!(MigrationRecordView); +::buffa::impl_view_reborrow!(MigrationRecordView); +/** Self-contained, `'static` owned view of a `MigrationRecord` message. + + Wraps [`::buffa::OwnedView`]`<`[`MigrationRecordView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MigrationRecordView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MigrationRecordOwnedView(::buffa::OwnedView>); +impl MigrationRecordOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationRecordOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationRecordOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MigrationRecord, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MigrationRecordOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MigrationRecordView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MigrationRecordView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MigrationRecord { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `intent` + #[must_use] + pub fn intent( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIntentView<'_>, + > { + &self.0.reborrow().intent + } + /// Field 2: `state` + #[must_use] + pub fn state(&self) -> ::buffa::EnumValue { + self.0.reborrow().state + } + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + #[must_use] + pub fn indeterminate( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'_>, + > { + &self.0.reborrow().indeterminate + } + /// The target as actually observed. Unset before any commit was attempted, and + /// unset after a reconciliation that found no target. + /// + /// Field 4: `observed_target` + #[must_use] + pub fn observed_target( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().observed_target + } + /// Attempts made under this identity. A rising count against an unchanged + /// state is the signal that a retry loop is not converging. + /// + /// Field 5: `attempt_count` + #[must_use] + pub fn attempt_count(&self) -> u32 { + self.0.reborrow().attempt_count + } + /// Field 6: `updated_at` + #[must_use] + pub fn updated_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().updated_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MigrationRecordOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MigrationRecordOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MigrationRecordOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MigrationRecordOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MigrationRecord { + type View<'a> = MigrationRecordView<'a>; + type ViewHandle = MigrationRecordOwnedView; +} +impl ::serde::Serialize for MigrationRecordOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// AdmissibilityDetail is why a migration was refused before writing anything. +/// +/// Every reason here is a reason to reach for salvage instead. A migration that +/// bends any of these rules keeps the session's identity while changing what its +/// ordinals mean, and nothing downstream would notice. +#[derive(Clone, Debug, Default)] +pub struct AdmissibilityDetailView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + /// The source position that triggered the refusal, where one did. + /// + /// Field 2: `ordinal` + pub ordinal: ::core::option::Option, + /// The source event type that triggered it, where one did. + /// + /// Field 3: `type_url` + pub type_url: ::core::option::Option<&'a str>, + /// Field 4: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> AdmissibilityDetailView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for AdmissibilityDetailView<'a> { + type Owned = super::super::AdmissibilityDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.type_url = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::AdmissibilityDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::AdmissibilityDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::AdmissibilityDetail { + reason: self.reason, + ordinal: self.ordinal, + type_url: self.type_url.map(|s| s.to_string()), + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for AdmissibilityDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.type_url { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(v) = self.ordinal { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(ref v) = self.type_url { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for AdmissibilityDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.ordinal { + __map.serialize_entry("ordinal", &::buffa::json_helpers::ProtoJson(&__v))?; + } + if let ::core::option::Option::Some(__v) = self.type_url { + __map.serialize_entry("typeUrl", __v)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for AdmissibilityDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "AdmissibilityDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail"; +} +::buffa::impl_default_view_instance!(AdmissibilityDetailView); +::buffa::impl_view_reborrow!(AdmissibilityDetailView); +/** Self-contained, `'static` owned view of a `AdmissibilityDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`AdmissibilityDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`AdmissibilityDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct AdmissibilityDetailOwnedView( + ::buffa::OwnedView>, +); +impl AdmissibilityDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AdmissibilityDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AdmissibilityDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::AdmissibilityDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AdmissibilityDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`AdmissibilityDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &AdmissibilityDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::AdmissibilityDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// The source position that triggered the refusal, where one did. + /// + /// Field 2: `ordinal` + #[must_use] + pub fn ordinal(&self) -> ::core::option::Option { + self.0.reborrow().ordinal + } + /// The source event type that triggered it, where one did. + /// + /// Field 3: `type_url` + #[must_use] + pub fn type_url(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().type_url + } + /// Field 4: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for AdmissibilityDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + AdmissibilityDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: AdmissibilityDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for AdmissibilityDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::AdmissibilityDetail { + type View<'a> = AdmissibilityDetailView<'a>; + type ViewHandle = AdmissibilityDetailOwnedView; +} +impl ::serde::Serialize for AdmissibilityDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.rs new file mode 100644 index 0000000000..1336f53b2c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.migration.rs @@ -0,0 +1,1478 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/migration.proto + +/// MigrationResult is the disposition of one MigrateSession call. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum MigrationResult { + MIGRATION_RESULT_UNSPECIFIED = 0i32, + /// This call performed the migration. + MIGRATION_RESULT_MIGRATED = 1i32, + /// The session was already at the target schema version and no work was + /// needed. Distinct from MIGRATED so a fleet run can report how much it + /// actually rewrote. + MIGRATION_RESULT_ALREADY_CURRENT = 2i32, + /// A prior attempt under this identity already committed. Reported instead of + /// MIGRATED so a retry never claims work it did not do, which is exactly the + /// claim the user's lost acknowledgment would otherwise produce. + MIGRATION_RESULT_ALREADY_MIGRATED = 3i32, + /// The plan was rejected before any write. Carries an AdmissibilityDetail. + MIGRATION_RESULT_NOT_ADMISSIBLE = 4i32, + /// The migration did not commit, and that is known. + MIGRATION_RESULT_FAILED = 5i32, + /// The outcome could not be classified. Carries an IndeterminateDetail on the + /// record. + MIGRATION_RESULT_INDETERMINATE = 6i32, + /// PLAN_ONLY: the plan is admissible and nothing was written. + MIGRATION_RESULT_WOULD_MIGRATE = 7i32, +} +impl MigrationResult { + ///Idiomatic alias for [`Self::MIGRATION_RESULT_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::MIGRATION_RESULT_UNSPECIFIED; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_MIGRATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Migrated: Self = Self::MIGRATION_RESULT_MIGRATED; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_ALREADY_CURRENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AlreadyCurrent: Self = Self::MIGRATION_RESULT_ALREADY_CURRENT; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_ALREADY_MIGRATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AlreadyMigrated: Self = Self::MIGRATION_RESULT_ALREADY_MIGRATED; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_NOT_ADMISSIBLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotAdmissible: Self = Self::MIGRATION_RESULT_NOT_ADMISSIBLE; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::MIGRATION_RESULT_FAILED; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_INDETERMINATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Indeterminate: Self = Self::MIGRATION_RESULT_INDETERMINATE; + ///Idiomatic alias for [`Self::MIGRATION_RESULT_WOULD_MIGRATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const WouldMigrate: Self = Self::MIGRATION_RESULT_WOULD_MIGRATE; +} +impl ::core::default::Default for MigrationResult { + fn default() -> Self { + Self::MIGRATION_RESULT_UNSPECIFIED + } +} +impl ::serde::Serialize for MigrationResult { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for MigrationResult { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = MigrationResult; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(MigrationResult) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationResult { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for MigrationResult { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_MIGRATED), + 2i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_ALREADY_CURRENT), + 3i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_ALREADY_MIGRATED), + 4i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_NOT_ADMISSIBLE), + 5i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_FAILED), + 6i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_INDETERMINATE), + 7i32 => ::core::option::Option::Some(Self::MIGRATION_RESULT_WOULD_MIGRATE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::MIGRATION_RESULT_UNSPECIFIED => "MIGRATION_RESULT_UNSPECIFIED", + Self::MIGRATION_RESULT_MIGRATED => "MIGRATION_RESULT_MIGRATED", + Self::MIGRATION_RESULT_ALREADY_CURRENT => "MIGRATION_RESULT_ALREADY_CURRENT", + Self::MIGRATION_RESULT_ALREADY_MIGRATED => { + "MIGRATION_RESULT_ALREADY_MIGRATED" + } + Self::MIGRATION_RESULT_NOT_ADMISSIBLE => "MIGRATION_RESULT_NOT_ADMISSIBLE", + Self::MIGRATION_RESULT_FAILED => "MIGRATION_RESULT_FAILED", + Self::MIGRATION_RESULT_INDETERMINATE => "MIGRATION_RESULT_INDETERMINATE", + Self::MIGRATION_RESULT_WOULD_MIGRATE => "MIGRATION_RESULT_WOULD_MIGRATE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "MIGRATION_RESULT_UNSPECIFIED" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_UNSPECIFIED) + } + "MIGRATION_RESULT_MIGRATED" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_MIGRATED) + } + "MIGRATION_RESULT_ALREADY_CURRENT" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_ALREADY_CURRENT) + } + "MIGRATION_RESULT_ALREADY_MIGRATED" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_ALREADY_MIGRATED) + } + "MIGRATION_RESULT_NOT_ADMISSIBLE" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_NOT_ADMISSIBLE) + } + "MIGRATION_RESULT_FAILED" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_FAILED) + } + "MIGRATION_RESULT_INDETERMINATE" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_INDETERMINATE) + } + "MIGRATION_RESULT_WOULD_MIGRATE" => { + ::core::option::Option::Some(Self::MIGRATION_RESULT_WOULD_MIGRATE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::MIGRATION_RESULT_UNSPECIFIED, + Self::MIGRATION_RESULT_MIGRATED, + Self::MIGRATION_RESULT_ALREADY_CURRENT, + Self::MIGRATION_RESULT_ALREADY_MIGRATED, + Self::MIGRATION_RESULT_NOT_ADMISSIBLE, + Self::MIGRATION_RESULT_FAILED, + Self::MIGRATION_RESULT_INDETERMINATE, + Self::MIGRATION_RESULT_WOULD_MIGRATE, + ] + } +} +/// AdmissibilityReason is the specific rule a plan violated. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum AdmissibilityReason { + ADMISSIBILITY_REASON_UNSPECIFIED = 0i32, + /// An event type in the source has no representation in the target schema. + /// Dropping it would renumber ordinals, so the migration refuses. + ADMISSIBILITY_REASON_TYPE_REMOVED = 1i32, + /// An event decoded and carries a value the target schema cannot express. + ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE = 2i32, + /// Source bytes did not decode. A migration transforms events it understands; + /// recovering ones it does not is salvage. + ADMISSIBILITY_REASON_SOURCE_UNDECODABLE = 3i32, + /// The transformation could not commit to a reproducible output, so a retry + /// could not be distinguished from a divergence. + ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC = 4i32, + /// The source is larger than the limits allowed for a single operation. + ADMISSIBILITY_REASON_SIZE_LIMIT = 5i32, + /// The source is still being written to. A migration of a moving stream is a + /// migration of an arbitrary prefix. + ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED = 6i32, + /// Another maintenance operation holds this session. + ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS = 7i32, +} +impl AdmissibilityReason { + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ADMISSIBILITY_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_TYPE_REMOVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const TypeRemoved: Self = Self::ADMISSIBILITY_REASON_TYPE_REMOVED; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const FieldUnrepresentable: Self = Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SourceUndecodable: Self = Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotByteDeterministic: Self = Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_SIZE_LIMIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SizeLimit: Self = Self::ADMISSIBILITY_REASON_SIZE_LIMIT; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SourceNotQuiesced: Self = Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED; + ///Idiomatic alias for [`Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationInProgress: Self = Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS; +} +impl ::core::default::Default for AdmissibilityReason { + fn default() -> Self { + Self::ADMISSIBILITY_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for AdmissibilityReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for AdmissibilityReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = AdmissibilityReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(AdmissibilityReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for AdmissibilityReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for AdmissibilityReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_TYPE_REMOVED), + 2i32 => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC, + ) + } + 5i32 => ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_SIZE_LIMIT), + 6i32 => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED, + ) + } + 7i32 => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ADMISSIBILITY_REASON_UNSPECIFIED => "ADMISSIBILITY_REASON_UNSPECIFIED", + Self::ADMISSIBILITY_REASON_TYPE_REMOVED => { + "ADMISSIBILITY_REASON_TYPE_REMOVED" + } + Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE => { + "ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE" + } + Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE => { + "ADMISSIBILITY_REASON_SOURCE_UNDECODABLE" + } + Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC => { + "ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC" + } + Self::ADMISSIBILITY_REASON_SIZE_LIMIT => "ADMISSIBILITY_REASON_SIZE_LIMIT", + Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED => { + "ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED" + } + Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS => { + "ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ADMISSIBILITY_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_UNSPECIFIED) + } + "ADMISSIBILITY_REASON_TYPE_REMOVED" => { + ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_TYPE_REMOVED) + } + "ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE" => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE, + ) + } + "ADMISSIBILITY_REASON_SOURCE_UNDECODABLE" => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE, + ) + } + "ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC" => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC, + ) + } + "ADMISSIBILITY_REASON_SIZE_LIMIT" => { + ::core::option::Option::Some(Self::ADMISSIBILITY_REASON_SIZE_LIMIT) + } + "ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED" => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED, + ) + } + "ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS" => { + ::core::option::Option::Some( + Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ADMISSIBILITY_REASON_UNSPECIFIED, + Self::ADMISSIBILITY_REASON_TYPE_REMOVED, + Self::ADMISSIBILITY_REASON_FIELD_UNREPRESENTABLE, + Self::ADMISSIBILITY_REASON_SOURCE_UNDECODABLE, + Self::ADMISSIBILITY_REASON_NOT_BYTE_DETERMINISTIC, + Self::ADMISSIBILITY_REASON_SIZE_LIMIT, + Self::ADMISSIBILITY_REASON_SOURCE_NOT_QUIESCED, + Self::ADMISSIBILITY_REASON_OPERATION_IN_PROGRESS, + ] + } +} +/// The durable record of a Session migration. +/// +/// A migration rewrites one session's stored events under a newer storage schema +/// and keeps the session's identity. Two rules make that safe, and both are +/// admissibility requirements rather than best effort: +/// +/// 1. Ordinals are preserved exactly. The target has the same event count as the +/// ```text +/// source, one transformed payload per source position. Inserting or removing +/// an event would renumber every following SessionOrdinal, and ordinals are +/// referenced from outside this stream: fork context boundaries on child +/// sessions, checkpoint evidence, consistency tokens, and page cursors would +/// all silently come to mean something else. +/// ``` +/// 2. The transformation is byte-deterministic. Given the same source bytes and +/// ```text +/// the same implementation_version, it produces the same target bytes. +/// ``` +/// +/// The second rule is what makes a lost commit acknowledgment recoverable: the +/// expected target digest can be written down before the commit, so a later look +/// at the target answers "did my write land" instead of "did some write land." +/// A transformation that cannot reproduce its own output is not a migration. It +/// is a salvage, and it must mint a new identity. +/// +/// MigrationIdentity is the retry identity of a migration. +/// +/// Two attempts sharing this tuple are the same migration and the second is +/// idempotent. Two attempts differing anywhere in it are different migrations, +/// and treating the second as a retry of the first is how a session gets +/// migrated twice. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrationIdentity { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Digest of the source cut. Part of identity because a migration of different + /// source content is a different migration even under the same version pair. + /// + /// Field 2: `source_digest` + #[serde(rename = "sourceDigest", alias = "source_digest")] + pub source_digest: ::buffa::MessageField< + ContentDigest, + ::buffa::Inline, + >, + /// Pins the transformation, including its encoder. Byte-determinism is scoped + /// to this value: a new encoder is a new implementation_version, because the + /// output bytes are part of what it promises. + /// + /// Field 3: `implementation_version` + #[serde( + rename = "implementationVersion", + alias = "implementation_version", + with = "::buffa::json_helpers::proto_string" + )] + pub implementation_version: ::buffa::alloc::string::String, + /// Field 4: `source_schema_version` + #[serde( + rename = "sourceSchemaVersion", + alias = "source_schema_version", + with = "::buffa::json_helpers::uint32" + )] + pub source_schema_version: u32, + /// Field 5: `target_schema_version` + #[serde( + rename = "targetSchemaVersion", + alias = "target_schema_version", + with = "::buffa::json_helpers::uint32" + )] + pub target_schema_version: u32, +} +impl ::core::fmt::Debug for MigrationIdentity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrationIdentity") + .field("session_id", &self.session_id) + .field("source_digest", &self.source_digest) + .field("implementation_version", &self.implementation_version) + .field("source_schema_version", &self.source_schema_version) + .field("target_schema_version", &self.target_schema_version) + .finish() + } +} +impl MigrationIdentity { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity"; +} +::buffa::impl_default_instance!(MigrationIdentity); +impl ::buffa::MessageName for MigrationIdentity { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationIdentity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity"; +} +impl ::buffa::Message for MigrationIdentity { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.implementation_version) + as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.source_schema_version) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.target_schema_version) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.implementation_version, buf); + ::buffa::types::put_uint32_field(4u32, self.source_schema_version, buf); + ::buffa::types::put_uint32_field(5u32, self.target_schema_version, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.implementation_version, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source_schema_version = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.target_schema_version = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.source_digest = ::buffa::MessageField::none(); + self.implementation_version.clear(); + self.source_schema_version = 0u32; + self.target_schema_version = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationIdentity { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATION_IDENTITY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIdentity", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// MigrationIntent is written durably before any target byte is written. +/// +/// This is the load-bearing record of the whole workflow. Reconciliation is a +/// comparison, and a comparison needs something recorded on the near side of the +/// crash. Without an intent, a process that dies mid-commit leaves a target that +/// nobody can attribute and nobody can safely replace. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrationIntent { + /// Field 1: `identity` + #[serde(rename = "identity")] + pub identity: ::buffa::MessageField< + MigrationIdentity, + ::buffa::Inline, + >, + /// Field 2: `source` + #[serde(rename = "source")] + pub source: ::buffa::MessageField>, + /// The boundary the target will have if the commit lands, computed before the + /// commit is attempted. `expected_target.ordinal` always equals + /// `source.ordinal`; a plan where they differ is not admissible. + /// + /// Field 3: `expected_target` + #[serde(rename = "expectedTarget", alias = "expected_target")] + pub expected_target: ::buffa::MessageField< + StreamBoundary, + ::buffa::Inline, + >, + /// Field 4: `actor` + #[serde(rename = "actor", with = "::buffa::json_helpers::proto_string")] + pub actor: ::buffa::alloc::string::String, + /// Why this migration was run. A migration is a rewrite of durable history, + /// and an unattributed rewrite is not auditable. + /// + /// Field 5: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_string")] + pub reason: ::buffa::alloc::string::String, + /// Field 6: `planned_at` + #[serde(rename = "plannedAt", alias = "planned_at")] + pub planned_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for MigrationIntent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrationIntent") + .field("identity", &self.identity) + .field("source", &self.source) + .field("expected_target", &self.expected_target) + .field("actor", &self.actor) + .field("reason", &self.reason) + .field("planned_at", &self.planned_at) + .finish() + } +} +impl MigrationIntent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent"; +} +::buffa::impl_default_instance!(MigrationIntent); +impl ::buffa::MessageName for MigrationIntent { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent"; +} +impl ::buffa::Message for MigrationIntent { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.expected_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if self.planned_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.planned_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + if self.source.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source.write_to(__cache, buf); + } + if self.expected_target.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_target.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.actor, buf); + ::buffa::types::put_string_field(5u32, &self.reason, buf); + if self.planned_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.planned_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.identity.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.expected_target.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.actor, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.reason, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.planned_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.identity = ::buffa::MessageField::none(); + self.source = ::buffa::MessageField::none(); + self.expected_target = ::buffa::MessageField::none(); + self.actor.clear(); + self.reason.clear(); + self.planned_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationIntent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATION_INTENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationIntent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// MigrationRecord is the intent plus everything learned since. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MigrationRecord { + /// Field 1: `intent` + #[serde(rename = "intent")] + pub intent: ::buffa::MessageField>, + /// Field 2: `state` + #[serde(rename = "state", with = "::buffa::json_helpers::proto_enum")] + pub state: ::buffa::EnumValue, + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + #[serde( + rename = "indeterminate", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub indeterminate: ::buffa::MessageField< + IndeterminateDetail, + ::buffa::Inline, + >, + /// The target as actually observed. Unset before any commit was attempted, and + /// unset after a reconciliation that found no target. + /// + /// Field 4: `observed_target` + #[serde( + rename = "observedTarget", + alias = "observed_target", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub observed_target: ::buffa::MessageField< + StreamBoundary, + ::buffa::Inline, + >, + /// Attempts made under this identity. A rising count against an unchanged + /// state is the signal that a retry loop is not converging. + /// + /// Field 5: `attempt_count` + #[serde( + rename = "attemptCount", + alias = "attempt_count", + with = "::buffa::json_helpers::uint32" + )] + pub attempt_count: u32, + /// Field 6: `updated_at` + #[serde(rename = "updatedAt", alias = "updated_at")] + pub updated_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for MigrationRecord { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MigrationRecord") + .field("intent", &self.intent) + .field("state", &self.state) + .field("indeterminate", &self.indeterminate) + .field("observed_target", &self.observed_target) + .field("attempt_count", &self.attempt_count) + .field("updated_at", &self.updated_at) + .finish() + } +} +impl MigrationRecord { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord"; +} +::buffa::impl_default_instance!(MigrationRecord); +impl ::buffa::MessageName for MigrationRecord { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "MigrationRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord"; +} +impl ::buffa::Message for MigrationRecord { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.updated_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.updated_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.intent.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intent.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.state.to_i32(), buf); + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.observed_target.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_target.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.attempt_count, buf); + if self.updated_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.updated_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.intent.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.indeterminate.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_target.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.attempt_count = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.updated_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.intent = ::buffa::MessageField::none(); + self.state = ::buffa::EnumValue::from(0); + self.indeterminate = ::buffa::MessageField::none(); + self.observed_target = ::buffa::MessageField::none(); + self.attempt_count = 0u32; + self.updated_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MigrationRecord { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MIGRATION_RECORD_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.MigrationRecord", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// AdmissibilityDetail is why a migration was refused before writing anything. +/// +/// Every reason here is a reason to reach for salvage instead. A migration that +/// bends any of these rules keeps the session's identity while changing what its +/// ordinals mean, and nothing downstream would notice. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct AdmissibilityDetail { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// The source position that triggered the refusal, where one did. + /// + /// Field 2: `ordinal` + #[serde( + rename = "ordinal", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub ordinal: ::core::option::Option, + /// The source event type that triggered it, where one did. + /// + /// Field 3: `type_url` + #[serde( + rename = "typeUrl", + alias = "type_url", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub type_url: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for AdmissibilityDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AdmissibilityDetail") + .field("reason", &self.reason) + .field("ordinal", &self.ordinal) + .field("type_url", &self.type_url) + .field("detail", &self.detail) + .finish() + } +} +impl AdmissibilityDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail"; +} +impl AdmissibilityDetail { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::ordinal`] to `Some(value)`, consuming and returning `self`. + pub fn with_ordinal(mut self, value: u64) -> Self { + self.ordinal = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::type_url`] to `Some(value)`, consuming and returning `self`. + pub fn with_type_url( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.type_url = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(AdmissibilityDetail); +impl ::buffa::MessageName for AdmissibilityDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "AdmissibilityDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail"; +} +impl ::buffa::Message for AdmissibilityDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.type_url { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(v) = self.ordinal { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(ref v) = self.type_url { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .type_url + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + self.ordinal = ::core::option::Option::None; + self.type_url = ::core::option::Option::None; + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for AdmissibilityDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ADMISSIBILITY_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.AdmissibilityDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.mod.rs new file mode 100644 index 0000000000..7967426ad7 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.mod.rs @@ -0,0 +1,157 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.outcome.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.migration.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.migrate_session.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.salvage.rs"); +include!("trogonai.session.sessions.maintenance.v1alpha1.salvage_session.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!( + "trogonai.session.sessions.maintenance.v1alpha1.maintenance_error.__view.rs" + ); + include!( + "trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.__view.rs" + ); + include!("trogonai.session.sessions.maintenance.v1alpha1.outcome.__view.rs"); + include!("trogonai.session.sessions.maintenance.v1alpha1.migration.__view.rs"); + include!( + "trogonai.session.sessions.maintenance.v1alpha1.migrate_session.__view.rs" + ); + include!( + "trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.__view.rs" + ); + include!("trogonai.session.sessions.maintenance.v1alpha1.salvage.__view.rs"); + include!( + "trogonai.session.sessions.maintenance.v1alpha1.salvage_session.__view.rs" + ); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__MAINTENANCE_ERROR_JSON_ANY); + reg.register_json_any(super::__STREAM_BOUNDARY_JSON_ANY); + reg.register_json_any(super::__CONTENT_DIGEST_JSON_ANY); + reg.register_json_any(super::__INDETERMINATE_DETAIL_JSON_ANY); + reg.register_json_any(super::__MIGRATION_IDENTITY_JSON_ANY); + reg.register_json_any(super::__MIGRATION_INTENT_JSON_ANY); + reg.register_json_any(super::__MIGRATION_RECORD_JSON_ANY); + reg.register_json_any(super::__ADMISSIBILITY_DETAIL_JSON_ANY); + reg.register_json_any(super::__MIGRATE_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__MIGRATION_LIMITS_JSON_ANY); + reg.register_json_any(super::__MIGRATE_SESSION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__RECONCILE_MIGRATION_REQUEST_JSON_ANY); + reg.register_json_any(super::__RECONCILE_MIGRATION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SALVAGE_IDENTITY_JSON_ANY); + reg.register_json_any(super::__SALVAGE_INTENT_JSON_ANY); + reg.register_json_any(super::__SALVAGE_RECORD_JSON_ANY); + reg.register_json_any(super::__OMITTED_ITEM_JSON_ANY); + reg.register_json_any(super::__REFUSAL_DETAIL_JSON_ANY); + reg.register_json_any(super::__SALVAGE_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__SALVAGE_LIMITS_JSON_ANY); + reg.register_json_any(super::__SALVAGE_SESSION_RESPONSE_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::MaintenanceErrorView; +#[doc(inline)] +pub use self::__buffa::view::MaintenanceErrorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StreamBoundaryView; +#[doc(inline)] +pub use self::__buffa::view::StreamBoundaryOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ContentDigestView; +#[doc(inline)] +pub use self::__buffa::view::ContentDigestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::IndeterminateDetailView; +#[doc(inline)] +pub use self::__buffa::view::IndeterminateDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrationIdentityView; +#[doc(inline)] +pub use self::__buffa::view::MigrationIdentityOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrationIntentView; +#[doc(inline)] +pub use self::__buffa::view::MigrationIntentOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrationRecordView; +#[doc(inline)] +pub use self::__buffa::view::MigrationRecordOwnedView; +#[doc(inline)] +pub use self::__buffa::view::AdmissibilityDetailView; +#[doc(inline)] +pub use self::__buffa::view::AdmissibilityDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrateSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::MigrateSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrationLimitsView; +#[doc(inline)] +pub use self::__buffa::view::MigrationLimitsOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MigrateSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::MigrateSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileMigrationRequestView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileMigrationRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileMigrationResponseView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileMigrationResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageIdentityView; +#[doc(inline)] +pub use self::__buffa::view::SalvageIdentityOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageIntentView; +#[doc(inline)] +pub use self::__buffa::view::SalvageIntentOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageRecordView; +#[doc(inline)] +pub use self::__buffa::view::SalvageRecordOwnedView; +#[doc(inline)] +pub use self::__buffa::view::OmittedItemView; +#[doc(inline)] +pub use self::__buffa::view::OmittedItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RefusalDetailView; +#[doc(inline)] +pub use self::__buffa::view::RefusalDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::SalvageSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageLimitsView; +#[doc(inline)] +pub use self::__buffa::view::SalvageLimitsOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SalvageSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::SalvageSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.__view.rs new file mode 100644 index 0000000000..4b04fa138a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.__view.rs @@ -0,0 +1,438 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/outcome.proto + +/// IndeterminateDetail is why an outcome could not be classified. +/// +/// COMMIT_UNKNOWN and INDETERMINATE are deliberately different states. +/// COMMIT_UNKNOWN says nobody has looked yet, and looking is a mechanical step +/// the workflow performs on its own. INDETERMINATE says the workflow looked and +/// the evidence does not decide. Indeterminate is a conclusion, not the absence +/// of one, and collapsing the two would make an unattended retry loop +/// indistinguishable from a problem that needs a human. +#[derive(Clone, Debug, Default)] +pub struct IndeterminateDetailView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + /// What the intent said should be there. + /// + /// Field 2: `expected` + pub expected: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// What was found. Unset means nothing was found, which is a different fact + /// from finding an empty stream, and the two lead to opposite actions. + /// + /// Field 3: `observed` + pub observed: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// For an operator. Never parsed. + /// + /// Field 4: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> IndeterminateDetailView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for IndeterminateDetailView<'a> { + type Owned = super::super::IndeterminateDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.expected.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.expected = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::IndeterminateDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::IndeterminateDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::IndeterminateDetail { + reason: self.reason, + expected: match self.expected.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed: match self.observed.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for IndeterminateDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.expected.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if self.expected.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected.write_to(__cache, buf); + } + if self.observed.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for IndeterminateDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + { + if let ::core::option::Option::Some(__v) = self.expected.as_option() { + __map.serialize_entry("expected", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed.as_option() { + __map.serialize_entry("observed", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for IndeterminateDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "IndeterminateDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail"; +} +::buffa::impl_default_view_instance!(IndeterminateDetailView); +::buffa::impl_view_reborrow!(IndeterminateDetailView); +/** Self-contained, `'static` owned view of a `IndeterminateDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`IndeterminateDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`IndeterminateDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct IndeterminateDetailOwnedView( + ::buffa::OwnedView>, +); +impl IndeterminateDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::IndeterminateDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`IndeterminateDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &IndeterminateDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::IndeterminateDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// What the intent said should be there. + /// + /// Field 2: `expected` + #[must_use] + pub fn expected( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().expected + } + /// What was found. Unset means nothing was found, which is a different fact + /// from finding an empty stream, and the two lead to opposite actions. + /// + /// Field 3: `observed` + #[must_use] + pub fn observed( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().observed + } + /// For an operator. Never parsed. + /// + /// Field 4: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for IndeterminateDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + IndeterminateDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: IndeterminateDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for IndeterminateDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::IndeterminateDetail { + type View<'a> = IndeterminateDetailView<'a>; + type ViewHandle = IndeterminateDetailOwnedView; +} +impl ::serde::Serialize for IndeterminateDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.rs new file mode 100644 index 0000000000..aac698bca0 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.outcome.rs @@ -0,0 +1,711 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/outcome.proto + +/// MaintenanceState is the lifecycle shared by migration and salvage. +/// +/// The two workflows differ in almost everything else and share this because +/// they share the same crash-exposed middle: durable work that is staged but not +/// yet authoritative, and a commit whose acknowledgment can be lost after the +/// commit itself succeeded. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum MaintenanceState { + MAINTENANCE_STATE_UNSPECIFIED = 0i32, + /// The intent is durable and no target write has been attempted. Recovering + /// from a crash here is free: nothing was written. + MAINTENANCE_STATE_PLANNED = 1i32, + /// Target content exists and is not yet the authoritative answer. + MAINTENANCE_STATE_STAGED = 2i32, + /// A commit was attempted and its outcome is not known. This is where a lost + /// acknowledgment lands. It is neither success nor failure, and the whole + /// reason the intent is written first is so this state can be left. + MAINTENANCE_STATE_COMMIT_UNKNOWN = 3i32, + MAINTENANCE_STATE_COMMITTED = 4i32, + /// The committed target was read back and matched the intent. + MAINTENANCE_STATE_VALIDATED = 5i32, + /// The workflow ended without committing, and that is known. + MAINTENANCE_STATE_FAILED = 6i32, + /// Reconciliation ran and could not classify the outcome. Terminal until an + /// operator acts. + MAINTENANCE_STATE_INDETERMINATE = 7i32, +} +impl MaintenanceState { + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::MAINTENANCE_STATE_UNSPECIFIED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_PLANNED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Planned: Self = Self::MAINTENANCE_STATE_PLANNED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_STAGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Staged: Self = Self::MAINTENANCE_STATE_STAGED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_COMMIT_UNKNOWN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CommitUnknown: Self = Self::MAINTENANCE_STATE_COMMIT_UNKNOWN; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_COMMITTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Committed: Self = Self::MAINTENANCE_STATE_COMMITTED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_VALIDATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Validated: Self = Self::MAINTENANCE_STATE_VALIDATED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::MAINTENANCE_STATE_FAILED; + ///Idiomatic alias for [`Self::MAINTENANCE_STATE_INDETERMINATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Indeterminate: Self = Self::MAINTENANCE_STATE_INDETERMINATE; +} +impl ::core::default::Default for MaintenanceState { + fn default() -> Self { + Self::MAINTENANCE_STATE_UNSPECIFIED + } +} +impl ::serde::Serialize for MaintenanceState { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for MaintenanceState { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = MaintenanceState; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(MaintenanceState) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for MaintenanceState { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for MaintenanceState { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_PLANNED), + 2i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_STAGED), + 3i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_COMMIT_UNKNOWN), + 4i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_COMMITTED), + 5i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_VALIDATED), + 6i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_FAILED), + 7i32 => ::core::option::Option::Some(Self::MAINTENANCE_STATE_INDETERMINATE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::MAINTENANCE_STATE_UNSPECIFIED => "MAINTENANCE_STATE_UNSPECIFIED", + Self::MAINTENANCE_STATE_PLANNED => "MAINTENANCE_STATE_PLANNED", + Self::MAINTENANCE_STATE_STAGED => "MAINTENANCE_STATE_STAGED", + Self::MAINTENANCE_STATE_COMMIT_UNKNOWN => "MAINTENANCE_STATE_COMMIT_UNKNOWN", + Self::MAINTENANCE_STATE_COMMITTED => "MAINTENANCE_STATE_COMMITTED", + Self::MAINTENANCE_STATE_VALIDATED => "MAINTENANCE_STATE_VALIDATED", + Self::MAINTENANCE_STATE_FAILED => "MAINTENANCE_STATE_FAILED", + Self::MAINTENANCE_STATE_INDETERMINATE => "MAINTENANCE_STATE_INDETERMINATE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "MAINTENANCE_STATE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_UNSPECIFIED) + } + "MAINTENANCE_STATE_PLANNED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_PLANNED) + } + "MAINTENANCE_STATE_STAGED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_STAGED) + } + "MAINTENANCE_STATE_COMMIT_UNKNOWN" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_COMMIT_UNKNOWN) + } + "MAINTENANCE_STATE_COMMITTED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_COMMITTED) + } + "MAINTENANCE_STATE_VALIDATED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_VALIDATED) + } + "MAINTENANCE_STATE_FAILED" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_FAILED) + } + "MAINTENANCE_STATE_INDETERMINATE" => { + ::core::option::Option::Some(Self::MAINTENANCE_STATE_INDETERMINATE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::MAINTENANCE_STATE_UNSPECIFIED, + Self::MAINTENANCE_STATE_PLANNED, + Self::MAINTENANCE_STATE_STAGED, + Self::MAINTENANCE_STATE_COMMIT_UNKNOWN, + Self::MAINTENANCE_STATE_COMMITTED, + Self::MAINTENANCE_STATE_VALIDATED, + Self::MAINTENANCE_STATE_FAILED, + Self::MAINTENANCE_STATE_INDETERMINATE, + ] + } +} +/// IndeterminateReason is the specific evidence gap. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum IndeterminateReason { + INDETERMINATE_REASON_UNSPECIFIED = 0i32, + /// A target exists where the intent said one would, and its content is not the + /// content this operation would have produced. Either something else wrote it + /// or a prior attempt wrote a truncated copy. Never overwrite: this is the one + /// reason that most invites a "just run it again" reflex and most punishes it. + INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH = 1i32, + /// The target exists and could not be read well enough to compare. Unreadable + /// is not absent, so nothing may be written on the strength of it. + INDETERMINATE_REASON_TARGET_UNREADABLE = 2i32, + /// The source advanced between the intent and the commit, so the staged target + /// is a transformation of a prefix. Committing it would silently discard every + /// event appended in between. + INDETERMINATE_REASON_SOURCE_ADVANCED = 3i32, + /// The source is no longer the stream incarnation the intent was cut from. + INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED = 4i32, + /// The authoritative order of source events could not be established. + INDETERMINATE_REASON_ORDER_UNPROVEN = 5i32, + /// Exclusive ownership of the target could not be proven, so a commit might + /// overwrite a concurrent writer. + INDETERMINATE_REASON_OWNERSHIP_UNPROVEN = 6i32, + /// No intent record was found for an operation that durable state shows was + /// started. There is nothing to compare against, which is what skipping the + /// intent-first rule costs. Named so its absence is a reportable condition + /// rather than a mystery. + INDETERMINATE_REASON_INTENT_MISSING = 7i32, +} +impl IndeterminateReason { + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::INDETERMINATE_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const TargetContentMismatch: Self = Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_TARGET_UNREADABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const TargetUnreadable: Self = Self::INDETERMINATE_REASON_TARGET_UNREADABLE; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_SOURCE_ADVANCED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SourceAdvanced: Self = Self::INDETERMINATE_REASON_SOURCE_ADVANCED; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SourceIncarnationChanged: Self = Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_ORDER_UNPROVEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OrderUnproven: Self = Self::INDETERMINATE_REASON_ORDER_UNPROVEN; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OwnershipUnproven: Self = Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN; + ///Idiomatic alias for [`Self::INDETERMINATE_REASON_INTENT_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IntentMissing: Self = Self::INDETERMINATE_REASON_INTENT_MISSING; +} +impl ::core::default::Default for IndeterminateReason { + fn default() -> Self { + Self::INDETERMINATE_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for IndeterminateReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for IndeterminateReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = IndeterminateReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(IndeterminateReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for IndeterminateReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for IndeterminateReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::INDETERMINATE_REASON_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH, + ) + } + 2i32 => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_TARGET_UNREADABLE, + ) + } + 3i32 => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_SOURCE_ADVANCED) + } + 4i32 => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED, + ) + } + 5i32 => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_ORDER_UNPROVEN) + } + 6i32 => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN, + ) + } + 7i32 => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_INTENT_MISSING) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::INDETERMINATE_REASON_UNSPECIFIED => "INDETERMINATE_REASON_UNSPECIFIED", + Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH => { + "INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH" + } + Self::INDETERMINATE_REASON_TARGET_UNREADABLE => { + "INDETERMINATE_REASON_TARGET_UNREADABLE" + } + Self::INDETERMINATE_REASON_SOURCE_ADVANCED => { + "INDETERMINATE_REASON_SOURCE_ADVANCED" + } + Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED => { + "INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED" + } + Self::INDETERMINATE_REASON_ORDER_UNPROVEN => { + "INDETERMINATE_REASON_ORDER_UNPROVEN" + } + Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN => { + "INDETERMINATE_REASON_OWNERSHIP_UNPROVEN" + } + Self::INDETERMINATE_REASON_INTENT_MISSING => { + "INDETERMINATE_REASON_INTENT_MISSING" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "INDETERMINATE_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_UNSPECIFIED) + } + "INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH" => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH, + ) + } + "INDETERMINATE_REASON_TARGET_UNREADABLE" => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_TARGET_UNREADABLE, + ) + } + "INDETERMINATE_REASON_SOURCE_ADVANCED" => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_SOURCE_ADVANCED) + } + "INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED" => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED, + ) + } + "INDETERMINATE_REASON_ORDER_UNPROVEN" => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_ORDER_UNPROVEN) + } + "INDETERMINATE_REASON_OWNERSHIP_UNPROVEN" => { + ::core::option::Option::Some( + Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN, + ) + } + "INDETERMINATE_REASON_INTENT_MISSING" => { + ::core::option::Option::Some(Self::INDETERMINATE_REASON_INTENT_MISSING) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::INDETERMINATE_REASON_UNSPECIFIED, + Self::INDETERMINATE_REASON_TARGET_CONTENT_MISMATCH, + Self::INDETERMINATE_REASON_TARGET_UNREADABLE, + Self::INDETERMINATE_REASON_SOURCE_ADVANCED, + Self::INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED, + Self::INDETERMINATE_REASON_ORDER_UNPROVEN, + Self::INDETERMINATE_REASON_OWNERSHIP_UNPROVEN, + Self::INDETERMINATE_REASON_INTENT_MISSING, + ] + } +} +/// IndeterminateDetail is why an outcome could not be classified. +/// +/// COMMIT_UNKNOWN and INDETERMINATE are deliberately different states. +/// COMMIT_UNKNOWN says nobody has looked yet, and looking is a mechanical step +/// the workflow performs on its own. INDETERMINATE says the workflow looked and +/// the evidence does not decide. Indeterminate is a conclusion, not the absence +/// of one, and collapsing the two would make an unattended retry loop +/// indistinguishable from a problem that needs a human. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct IndeterminateDetail { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// What the intent said should be there. + /// + /// Field 2: `expected` + #[serde( + rename = "expected", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub expected: ::buffa::MessageField>, + /// What was found. Unset means nothing was found, which is a different fact + /// from finding an empty stream, and the two lead to opposite actions. + /// + /// Field 3: `observed` + #[serde( + rename = "observed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub observed: ::buffa::MessageField>, + /// For an operator. Never parsed. + /// + /// Field 4: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for IndeterminateDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("IndeterminateDetail") + .field("reason", &self.reason) + .field("expected", &self.expected) + .field("observed", &self.observed) + .field("detail", &self.detail) + .finish() + } +} +impl IndeterminateDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail"; +} +impl IndeterminateDetail { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(IndeterminateDetail); +impl ::buffa::MessageName for IndeterminateDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "IndeterminateDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail"; +} +impl ::buffa::Message for IndeterminateDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.expected.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if self.expected.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected.write_to(__cache, buf); + } + if self.observed.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.expected.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + self.expected = ::buffa::MessageField::none(); + self.observed = ::buffa::MessageField::none(); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for IndeterminateDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __INDETERMINATE_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.IndeterminateDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.__view.rs new file mode 100644 index 0000000000..4a0b7fe3e0 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.__view.rs @@ -0,0 +1,855 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/reconcile_migration.proto + +/// ReconcileMigration resolves a migration whose commit outcome is unknown. +/// +/// It reads. There is no mode, no force, and no field that could make it write, +/// for the same reason DiagnoseSession has none: a reconciler that can also +/// commit is a reconciler that can blindly commit, and blindly copying a session +/// again is precisely the failure this workflow exists to prevent. Acting on a +/// verdict is a separate MigrateSession call, made by whoever read the verdict. +#[derive(Clone, Debug, Default)] +pub struct ReconcileMigrationRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The identity from the recorded intent. Reconciliation compares against what + /// was planned, so a caller with no intent has nothing to reconcile and gets + /// INDETERMINATE_REASON_INTENT_MISSING rather than a guess. + /// + /// Field 2: `identity` + pub identity: ::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIdentityView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileMigrationRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `identity` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_identity(&self) -> bool { + self.identity.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileMigrationRequestView<'a> { + type Owned = super::super::ReconcileMigrationRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.identity.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.identity = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileMigrationRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileMigrationRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileMigrationRequest { + session_id: self.session_id.to_string(), + identity: match self.identity.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::MigrationIdentity, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileMigrationRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileMigrationRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.identity.as_option() { + __map.serialize_entry("identity", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileMigrationRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ReconcileMigrationRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest"; +} +::buffa::impl_default_view_instance!(ReconcileMigrationRequestView); +::buffa::impl_view_reborrow!(ReconcileMigrationRequestView); +/** Self-contained, `'static` owned view of a `ReconcileMigrationRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileMigrationRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileMigrationRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileMigrationRequestOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileMigrationRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileMigrationRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileMigrationRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileMigrationRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileMigrationRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The identity from the recorded intent. Reconciliation compares against what + /// was planned, so a caller with no intent has nothing to reconcile and gets + /// INDETERMINATE_REASON_INTENT_MISSING rather than a guess. + /// + /// Field 2: `identity` + #[must_use] + pub fn identity( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::MigrationIdentityView<'_>, + > { + &self.0.reborrow().identity + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileMigrationRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReconcileMigrationRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileMigrationRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileMigrationRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileMigrationRequest { + type View<'a> = ReconcileMigrationRequestView<'a>; + type ViewHandle = ReconcileMigrationRequestOwnedView; +} +impl ::serde::Serialize for ReconcileMigrationRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct ReconcileMigrationResponseView<'a> { + /// Field 1: `verdict` + pub verdict: ::buffa::EnumValue, + /// The state the record should be moved to. Reported rather than applied, + /// because applying it is a write. + /// + /// Field 2: `resolved_state` + pub resolved_state: ::buffa::EnumValue, + /// What was found at the target location. Unset when nothing was found. + /// + /// Field 3: `observed_target` + pub observed_target: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// Set only for RECONCILIATION_VERDICT_UNRESOLVED. + /// + /// Field 4: `indeterminate` + pub indeterminate: ::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'a>, + >, + /// Field 5: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileMigrationResponseView<'a> { + /**Whether required field `verdict` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_verdict(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `resolved_state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_resolved_state(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileMigrationResponseView<'a> { + type Owned = super::super::ReconcileMigrationResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.verdict = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.resolved_state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_target.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_target = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.indeterminate.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.indeterminate = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileMigrationResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileMigrationResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileMigrationResponse { + verdict: self.verdict, + resolved_state: self.resolved_state, + observed_target: match self.observed_target.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + indeterminate: match self.indeterminate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::IndeterminateDetail, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileMigrationResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.verdict.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.resolved_state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.observed_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.verdict.to_i32(), buf); + ::buffa::types::put_int32_field(2u32, self.resolved_state.to_i32(), buf); + if self.observed_target.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_target.write_to(__cache, buf); + } + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileMigrationResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("verdict", &self.verdict)?; + } + { + __map.serialize_entry("resolvedState", &self.resolved_state)?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_target.as_option() { + __map.serialize_entry("observedTarget", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.indeterminate.as_option() { + __map.serialize_entry("indeterminate", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileMigrationResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ReconcileMigrationResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse"; +} +::buffa::impl_default_view_instance!(ReconcileMigrationResponseView); +::buffa::impl_view_reborrow!(ReconcileMigrationResponseView); +/** Self-contained, `'static` owned view of a `ReconcileMigrationResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileMigrationResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileMigrationResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileMigrationResponseOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileMigrationResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileMigrationResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileMigrationResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileMigrationResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileMigrationResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileMigrationResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `verdict` + #[must_use] + pub fn verdict(&self) -> ::buffa::EnumValue { + self.0.reborrow().verdict + } + /// The state the record should be moved to. Reported rather than applied, + /// because applying it is a write. + /// + /// Field 2: `resolved_state` + #[must_use] + pub fn resolved_state(&self) -> ::buffa::EnumValue { + self.0.reborrow().resolved_state + } + /// What was found at the target location. Unset when nothing was found. + /// + /// Field 3: `observed_target` + #[must_use] + pub fn observed_target( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().observed_target + } + /// Set only for RECONCILIATION_VERDICT_UNRESOLVED. + /// + /// Field 4: `indeterminate` + #[must_use] + pub fn indeterminate( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'_>, + > { + &self.0.reborrow().indeterminate + } + /// Field 5: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileMigrationResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReconcileMigrationResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileMigrationResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileMigrationResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileMigrationResponse { + type View<'a> = ReconcileMigrationResponseView<'a>; + type ViewHandle = ReconcileMigrationResponseOwnedView; +} +impl ::serde::Serialize for ReconcileMigrationResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.rs new file mode 100644 index 0000000000..3401998844 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.reconcile_migration.rs @@ -0,0 +1,597 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/reconcile_migration.proto + +/// ReconciliationVerdict is what the durable evidence says happened. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ReconciliationVerdict { + RECONCILIATION_VERDICT_UNSPECIFIED = 0i32, + /// No target exists. The commit did not land, and a retry under the same + /// identity is safe. + RECONCILIATION_VERDICT_NOT_COMMITTED = 1i32, + /// A target exists and its boundary matches the intent exactly. The commit + /// landed and the acknowledgment was the only thing lost. The correct action + /// is to record success, not to migrate again. + RECONCILIATION_VERDICT_COMMITTED = 2i32, + /// A target exists and does not match the intent. Fail closed: no automated + /// action may resolve this, because both readings, a truncated copy of ours + /// and an intact copy of somebody else's, look identical from here. + RECONCILIATION_VERDICT_DIVERGED = 3i32, + /// The comparison itself could not be made. + RECONCILIATION_VERDICT_UNRESOLVED = 4i32, +} +impl ReconciliationVerdict { + ///Idiomatic alias for [`Self::RECONCILIATION_VERDICT_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RECONCILIATION_VERDICT_UNSPECIFIED; + ///Idiomatic alias for [`Self::RECONCILIATION_VERDICT_NOT_COMMITTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotCommitted: Self = Self::RECONCILIATION_VERDICT_NOT_COMMITTED; + ///Idiomatic alias for [`Self::RECONCILIATION_VERDICT_COMMITTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Committed: Self = Self::RECONCILIATION_VERDICT_COMMITTED; + ///Idiomatic alias for [`Self::RECONCILIATION_VERDICT_DIVERGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Diverged: Self = Self::RECONCILIATION_VERDICT_DIVERGED; + ///Idiomatic alias for [`Self::RECONCILIATION_VERDICT_UNRESOLVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unresolved: Self = Self::RECONCILIATION_VERDICT_UNRESOLVED; +} +impl ::core::default::Default for ReconciliationVerdict { + fn default() -> Self { + Self::RECONCILIATION_VERDICT_UNSPECIFIED + } +} +impl ::serde::Serialize for ReconciliationVerdict { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ReconciliationVerdict { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ReconciliationVerdict; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ReconciliationVerdict) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconciliationVerdict { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ReconciliationVerdict { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_UNSPECIFIED) + } + 1i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_NOT_COMMITTED) + } + 2i32 => ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_COMMITTED), + 3i32 => ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_DIVERGED), + 4i32 => ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_UNRESOLVED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RECONCILIATION_VERDICT_UNSPECIFIED => { + "RECONCILIATION_VERDICT_UNSPECIFIED" + } + Self::RECONCILIATION_VERDICT_NOT_COMMITTED => { + "RECONCILIATION_VERDICT_NOT_COMMITTED" + } + Self::RECONCILIATION_VERDICT_COMMITTED => "RECONCILIATION_VERDICT_COMMITTED", + Self::RECONCILIATION_VERDICT_DIVERGED => "RECONCILIATION_VERDICT_DIVERGED", + Self::RECONCILIATION_VERDICT_UNRESOLVED => { + "RECONCILIATION_VERDICT_UNRESOLVED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RECONCILIATION_VERDICT_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_UNSPECIFIED) + } + "RECONCILIATION_VERDICT_NOT_COMMITTED" => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_NOT_COMMITTED) + } + "RECONCILIATION_VERDICT_COMMITTED" => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_COMMITTED) + } + "RECONCILIATION_VERDICT_DIVERGED" => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_DIVERGED) + } + "RECONCILIATION_VERDICT_UNRESOLVED" => { + ::core::option::Option::Some(Self::RECONCILIATION_VERDICT_UNRESOLVED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RECONCILIATION_VERDICT_UNSPECIFIED, + Self::RECONCILIATION_VERDICT_NOT_COMMITTED, + Self::RECONCILIATION_VERDICT_COMMITTED, + Self::RECONCILIATION_VERDICT_DIVERGED, + Self::RECONCILIATION_VERDICT_UNRESOLVED, + ] + } +} +/// ReconcileMigration resolves a migration whose commit outcome is unknown. +/// +/// It reads. There is no mode, no force, and no field that could make it write, +/// for the same reason DiagnoseSession has none: a reconciler that can also +/// commit is a reconciler that can blindly commit, and blindly copying a session +/// again is precisely the failure this workflow exists to prevent. Acting on a +/// verdict is a separate MigrateSession call, made by whoever read the verdict. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileMigrationRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The identity from the recorded intent. Reconciliation compares against what + /// was planned, so a caller with no intent has nothing to reconcile and gets + /// INDETERMINATE_REASON_INTENT_MISSING rather than a guess. + /// + /// Field 2: `identity` + #[serde(rename = "identity")] + pub identity: ::buffa::MessageField< + MigrationIdentity, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ReconcileMigrationRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileMigrationRequest") + .field("session_id", &self.session_id) + .field("identity", &self.identity) + .finish() + } +} +impl ReconcileMigrationRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest"; +} +::buffa::impl_default_instance!(ReconcileMigrationRequest); +impl ::buffa::MessageName for ReconcileMigrationRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ReconcileMigrationRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest"; +} +impl ::buffa::Message for ReconcileMigrationRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.identity.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.identity = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileMigrationRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_MIGRATION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileMigrationResponse { + /// Field 1: `verdict` + #[serde(rename = "verdict", with = "::buffa::json_helpers::proto_enum")] + pub verdict: ::buffa::EnumValue, + /// The state the record should be moved to. Reported rather than applied, + /// because applying it is a write. + /// + /// Field 2: `resolved_state` + #[serde( + rename = "resolvedState", + alias = "resolved_state", + with = "::buffa::json_helpers::proto_enum" + )] + pub resolved_state: ::buffa::EnumValue, + /// What was found at the target location. Unset when nothing was found. + /// + /// Field 3: `observed_target` + #[serde( + rename = "observedTarget", + alias = "observed_target", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub observed_target: ::buffa::MessageField< + StreamBoundary, + ::buffa::Inline, + >, + /// Set only for RECONCILIATION_VERDICT_UNRESOLVED. + /// + /// Field 4: `indeterminate` + #[serde( + rename = "indeterminate", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub indeterminate: ::buffa::MessageField< + IndeterminateDetail, + ::buffa::Inline, + >, + /// Field 5: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ReconcileMigrationResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileMigrationResponse") + .field("verdict", &self.verdict) + .field("resolved_state", &self.resolved_state) + .field("observed_target", &self.observed_target) + .field("indeterminate", &self.indeterminate) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl ReconcileMigrationResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse"; +} +::buffa::impl_default_instance!(ReconcileMigrationResponse); +impl ::buffa::MessageName for ReconcileMigrationResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ReconcileMigrationResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse"; +} +impl ::buffa::Message for ReconcileMigrationResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.verdict.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.resolved_state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.observed_target.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_target.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.verdict.to_i32(), buf); + ::buffa::types::put_int32_field(2u32, self.resolved_state.to_i32(), buf); + if self.observed_target.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_target.write_to(__cache, buf); + } + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.verdict = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.resolved_state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_target.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.indeterminate.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.verdict = ::buffa::EnumValue::from(0); + self.resolved_state = ::buffa::EnumValue::from(0); + self.observed_target = ::buffa::MessageField::none(); + self.indeterminate = ::buffa::MessageField::none(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileMigrationResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_MIGRATION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ReconcileMigrationResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.__view.rs new file mode 100644 index 0000000000..e9881e951d --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.__view.rs @@ -0,0 +1,2064 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/salvage.proto + +/// The durable record of a Session salvage. +/// +/// A salvage copies what can be read from a damaged session into a new session +/// identity. It is the opposite of a migration on every axis that matters: +/// +/// | | migration | salvage | +/// | identity | preserved | new | +/// | ordinals | preserved exactly | not preserved | +/// | source | must be intact | is damaged | +/// | source after | replaced | untouched | +/// | loss | inadmissible | expected and enumerated | +/// +/// It is also not ForkSession. A fork inherits a prefix it assumes is valid and +/// references it in place, so the source must stay readable forever. A salvage +/// exists because the source's validity is incomplete, so it copies, and the +/// copy is a different session that must never be presented as the original. +/// +/// SalvageIdentity is the retry identity of a salvage. +#[derive(Clone, Debug, Default)] +pub struct SalvageIdentityView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// Chosen by the operator or orchestrator. Two salvages of one damaged source + /// are legitimately different operations, so identity cannot be derived from + /// the source alone. + /// + /// Field 2: `salvage_key` + pub salvage_key: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SalvageIdentityView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `salvage_key` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_salvage_key(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SalvageIdentityView<'a> { + type Owned = super::super::SalvageIdentity; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.salvage_key = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageIdentity { + source_session_id: self.source_session_id.to_string(), + salvage_key: self.salvage_key.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageIdentityView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_string_field(2u32, &self.salvage_key, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageIdentityView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + __map.serialize_entry("salvageKey", self.salvage_key)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageIdentityView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageIdentity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity"; +} +::buffa::impl_default_view_instance!(SalvageIdentityView); +::buffa::impl_view_reborrow!(SalvageIdentityView); +/** Self-contained, `'static` owned view of a `SalvageIdentity` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageIdentityView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageIdentityView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageIdentityOwnedView(::buffa::OwnedView>); +impl SalvageIdentityOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIdentityOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIdentityOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageIdentity, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIdentityOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageIdentityView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageIdentityView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageIdentity { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// Chosen by the operator or orchestrator. Two salvages of one damaged source + /// are legitimately different operations, so identity cannot be derived from + /// the source alone. + /// + /// Field 2: `salvage_key` + #[must_use] + pub fn salvage_key(&self) -> &'_ str { + self.0.reborrow().salvage_key + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageIdentityOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageIdentityOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageIdentityOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageIdentityOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageIdentity { + type View<'a> = SalvageIdentityView<'a>; + type ViewHandle = SalvageIdentityOwnedView; +} +impl ::serde::Serialize for SalvageIdentityOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SalvageIntent is written durably before the target session is created. +#[derive(Clone, Debug, Default)] +pub struct SalvageIntentView<'a> { + /// Field 1: `identity` + pub identity: ::buffa::MessageFieldView< + super::super::__buffa::view::SalvageIdentityView<'a>, + >, + /// Field 2: `source` + pub source: ::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'a>, + >, + /// The id the salvaged session will have, derived from the identity before any + /// write is attempted. + /// + /// Deriving it is what makes a retry safe. The salvaged session is created by + /// an atomic batch under a NoStream precondition, so a retry that lands on the + /// same id sees a visible conflict instead of producing a second copy. A + /// randomly minted id would leave a retry unable to find its own prior work, + /// which is the same trap the migration reconciler exists to escape, closed + /// here by the write precondition rather than by a later comparison. + /// + /// Field 3: `target_session_id` + pub target_session_id: &'a str, + /// Field 4: `order_proof` + pub order_proof: ::buffa::EnumValue, + /// Field 5: `actor` + pub actor: &'a str, + /// Field 6: `reason` + pub reason: &'a str, + /// Field 7: `planned_at` + pub planned_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SalvageIntentView<'a> { + /**Whether required field `identity` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_identity(&self) -> bool { + self.identity.is_set() + } + /**Whether required field `source` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source(&self) -> bool { + self.source.is_set() + } + /**Whether required field `target_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_target_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `order_proof` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_order_proof(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `actor` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_actor(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `planned_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_planned_at(&self) -> bool { + self.planned_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SalvageIntentView<'a> { + type Owned = super::super::SalvageIntent; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.identity.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.identity = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.target_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.order_proof = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.actor = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.planned_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.planned_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageIntent { + identity: match self.identity.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SalvageIdentity, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source: match self.source.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StreamBoundary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + target_session_id: self.target_session_id.to_string(), + order_proof: self.order_proof, + actor: self.actor.to_string(), + reason: self.reason.to_string(), + planned_at: match self.planned_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageIntentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.target_session_id) as u64; + { + let val = self.order_proof.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if self.planned_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.planned_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + if self.source.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.target_session_id, buf); + ::buffa::types::put_int32_field(4u32, self.order_proof.to_i32(), buf); + ::buffa::types::put_string_field(5u32, &self.actor, buf); + ::buffa::types::put_string_field(6u32, &self.reason, buf); + if self.planned_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.planned_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageIntentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.identity.as_option() { + __map.serialize_entry("identity", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.source.as_option() { + __map.serialize_entry("source", __v)?; + } + } + { + __map.serialize_entry("targetSessionId", self.target_session_id)?; + } + { + __map.serialize_entry("orderProof", &self.order_proof)?; + } + { + __map.serialize_entry("actor", self.actor)?; + } + { + __map.serialize_entry("reason", self.reason)?; + } + { + if let ::core::option::Option::Some(__v) = self.planned_at.as_option() { + __map.serialize_entry("plannedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageIntentView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent"; +} +::buffa::impl_default_view_instance!(SalvageIntentView); +::buffa::impl_view_reborrow!(SalvageIntentView); +/** Self-contained, `'static` owned view of a `SalvageIntent` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageIntentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageIntentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageIntentOwnedView(::buffa::OwnedView>); +impl SalvageIntentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIntentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIntentOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageIntent, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageIntentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageIntentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageIntentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageIntent { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `identity` + #[must_use] + pub fn identity( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SalvageIdentityView<'_>, + > { + &self.0.reborrow().identity + } + /// Field 2: `source` + #[must_use] + pub fn source( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StreamBoundaryView<'_>, + > { + &self.0.reborrow().source + } + /// The id the salvaged session will have, derived from the identity before any + /// write is attempted. + /// + /// Deriving it is what makes a retry safe. The salvaged session is created by + /// an atomic batch under a NoStream precondition, so a retry that lands on the + /// same id sees a visible conflict instead of producing a second copy. A + /// randomly minted id would leave a retry unable to find its own prior work, + /// which is the same trap the migration reconciler exists to escape, closed + /// here by the write precondition rather than by a later comparison. + /// + /// Field 3: `target_session_id` + #[must_use] + pub fn target_session_id(&self) -> &'_ str { + self.0.reborrow().target_session_id + } + /// Field 4: `order_proof` + #[must_use] + pub fn order_proof(&self) -> ::buffa::EnumValue { + self.0.reborrow().order_proof + } + /// Field 5: `actor` + #[must_use] + pub fn actor(&self) -> &'_ str { + self.0.reborrow().actor + } + /// Field 6: `reason` + #[must_use] + pub fn reason(&self) -> &'_ str { + self.0.reborrow().reason + } + /// Field 7: `planned_at` + #[must_use] + pub fn planned_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().planned_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageIntentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageIntentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageIntentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageIntentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageIntent { + type View<'a> = SalvageIntentView<'a>; + type ViewHandle = SalvageIntentOwnedView; +} +impl ::serde::Serialize for SalvageIntentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SalvageRecord is the intent plus everything learned since. +#[derive(Clone, Debug, Default)] +pub struct SalvageRecordView<'a> { + /// Field 1: `intent` + pub intent: ::buffa::MessageFieldView< + super::super::__buffa::view::SalvageIntentView<'a>, + >, + /// Field 2: `state` + pub state: ::buffa::EnumValue, + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + pub indeterminate: ::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'a>, + >, + /// Everything the source held that the salvaged session does not. + /// + /// Field 4: `omitted` + pub omitted: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::OmittedItemView<'a>, + >, + /// Field 5: `attempt_count` + pub attempt_count: u32, + /// Field 6: `updated_at` + pub updated_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SalvageRecordView<'a> { + /**Whether required field `intent` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_intent(&self) -> bool { + self.intent.is_set() + } + /**Whether required field `state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_state(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `attempt_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_attempt_count(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `updated_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_updated_at(&self) -> bool { + self.updated_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SalvageRecordView<'a> { + type Owned = super::super::SalvageRecord; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.intent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.intent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.indeterminate.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.indeterminate = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.attempt_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.updated_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.updated_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::OmittedItemView, + >(), + )?; + view.omitted + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageRecord { + intent: match self.intent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SalvageIntent, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + state: self.state, + indeterminate: match self.indeterminate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::IndeterminateDetail, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + omitted: self + .omitted + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + attempt_count: self.attempt_count, + updated_at: match self.updated_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageRecordView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.omitted { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.updated_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.updated_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.intent.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intent.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.state.to_i32(), buf); + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + for v in &self.omitted { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.attempt_count, buf); + if self.updated_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.updated_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageRecordView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.intent.as_option() { + __map.serialize_entry("intent", __v)?; + } + } + { + __map.serialize_entry("state", &self.state)?; + } + { + if let ::core::option::Option::Some(__v) = self.indeterminate.as_option() { + __map.serialize_entry("indeterminate", __v)?; + } + } + if !self.omitted.is_empty() { + __map.serialize_entry("omitted", &*self.omitted)?; + } + { + __map + .serialize_entry( + "attemptCount", + &::buffa::json_helpers::ProtoJson(&self.attempt_count), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.updated_at.as_option() { + __map.serialize_entry("updatedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageRecordView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord"; +} +::buffa::impl_default_view_instance!(SalvageRecordView); +::buffa::impl_view_reborrow!(SalvageRecordView); +/** Self-contained, `'static` owned view of a `SalvageRecord` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageRecordView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageRecordView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageRecordOwnedView(::buffa::OwnedView>); +impl SalvageRecordOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageRecordOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageRecordOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageRecord, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageRecordOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageRecordView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageRecordView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageRecord { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `intent` + #[must_use] + pub fn intent( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().intent + } + /// Field 2: `state` + #[must_use] + pub fn state(&self) -> ::buffa::EnumValue { + self.0.reborrow().state + } + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + #[must_use] + pub fn indeterminate( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateDetailView<'_>, + > { + &self.0.reborrow().indeterminate + } + /// Everything the source held that the salvaged session does not. + /// + /// Field 4: `omitted` + #[must_use] + pub fn omitted( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OmittedItemView<'_>> { + &self.0.reborrow().omitted + } + /// Field 5: `attempt_count` + #[must_use] + pub fn attempt_count(&self) -> u32 { + self.0.reborrow().attempt_count + } + /// Field 6: `updated_at` + #[must_use] + pub fn updated_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().updated_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageRecordOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageRecordOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageRecordOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageRecordOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageRecord { + type View<'a> = SalvageRecordView<'a>; + type ViewHandle = SalvageRecordOwnedView; +} +impl ::serde::Serialize for SalvageRecordOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// OmittedItem is one thing the salvage could not carry. +/// +/// Enumerated rather than counted. An operator told that three things were lost +/// cannot tell whether they were three tool results or three user messages, and +/// that difference decides whether the salvaged session is worth keeping. +#[derive(Clone, Debug, Default)] +pub struct OmittedItemView<'a> { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// The source position, for an omission that had one. + /// + /// Field 2: `source_ordinal` + pub source_ordinal: ::core::option::Option, + /// The artifact, checkpoint, or child session id, for an omission that had one. + /// + /// Field 3: `entity_id` + pub entity_id: ::core::option::Option<&'a str>, + /// Field 4: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> OmittedItemView<'a> { + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for OmittedItemView<'a> { + type Owned = super::super::OmittedItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source_ordinal = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.entity_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::OmittedItem { + kind: self.kind, + source_ordinal: self.source_ordinal, + entity_id: self.entity_id.map(|s| s.to_string()), + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for OmittedItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.source_ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.entity_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if let Some(v) = self.source_ordinal { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(ref v) = self.entity_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_int32_field(4u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for OmittedItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(__v) = self.source_ordinal { + __map + .serialize_entry( + "sourceOrdinal", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.entity_id { + __map.serialize_entry("entityId", __v)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for OmittedItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "OmittedItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.OmittedItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.OmittedItem"; +} +::buffa::impl_default_view_instance!(OmittedItemView); +::buffa::impl_view_reborrow!(OmittedItemView); +/** Self-contained, `'static` owned view of a `OmittedItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`OmittedItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OmittedItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct OmittedItemOwnedView(::buffa::OwnedView>); +impl OmittedItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OmittedItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OmittedItemOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::OmittedItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OmittedItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`OmittedItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &OmittedItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::OmittedItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// The source position, for an omission that had one. + /// + /// Field 2: `source_ordinal` + #[must_use] + pub fn source_ordinal(&self) -> ::core::option::Option { + self.0.reborrow().source_ordinal + } + /// The artifact, checkpoint, or child session id, for an omission that had one. + /// + /// Field 3: `entity_id` + #[must_use] + pub fn entity_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().entity_id + } + /// Field 4: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for OmittedItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + OmittedItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: OmittedItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for OmittedItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::OmittedItem { + type View<'a> = OmittedItemView<'a>; + type ViewHandle = OmittedItemOwnedView; +} +impl ::serde::Serialize for OmittedItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RefusalDetail is why a salvage wrote nothing. +#[derive(Clone, Debug, Default)] +pub struct RefusalDetailView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + /// Field 2: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RefusalDetailView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RefusalDetailView<'a> { + type Owned = super::super::RefusalDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RefusalDetail { + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RefusalDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(2u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RefusalDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RefusalDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "RefusalDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail"; +} +::buffa::impl_default_view_instance!(RefusalDetailView); +::buffa::impl_view_reborrow!(RefusalDetailView); +/** Self-contained, `'static` owned view of a `RefusalDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`RefusalDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RefusalDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RefusalDetailOwnedView(::buffa::OwnedView>); +impl RefusalDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RefusalDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RefusalDetailOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RefusalDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RefusalDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RefusalDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RefusalDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RefusalDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 2: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RefusalDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RefusalDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RefusalDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RefusalDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RefusalDetail { + type View<'a> = RefusalDetailView<'a>; + type ViewHandle = RefusalDetailOwnedView; +} +impl ::serde::Serialize for RefusalDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.rs new file mode 100644 index 0000000000..646c23be9c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage.rs @@ -0,0 +1,1816 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/salvage.proto + +/// OmittedKind is what sort of thing was lost. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum OmittedKind { + OMITTED_KIND_UNSPECIFIED = 0i32, + OMITTED_KIND_EVENT = 1i32, + OMITTED_KIND_ARTIFACT = 2i32, + OMITTED_KIND_CHECKPOINT = 3i32, + OMITTED_KIND_CHILD_SESSION = 4i32, +} +impl OmittedKind { + ///Idiomatic alias for [`Self::OMITTED_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::OMITTED_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::OMITTED_KIND_EVENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Event: Self = Self::OMITTED_KIND_EVENT; + ///Idiomatic alias for [`Self::OMITTED_KIND_ARTIFACT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Artifact: Self = Self::OMITTED_KIND_ARTIFACT; + ///Idiomatic alias for [`Self::OMITTED_KIND_CHECKPOINT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Checkpoint: Self = Self::OMITTED_KIND_CHECKPOINT; + ///Idiomatic alias for [`Self::OMITTED_KIND_CHILD_SESSION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChildSession: Self = Self::OMITTED_KIND_CHILD_SESSION; +} +impl ::core::default::Default for OmittedKind { + fn default() -> Self { + Self::OMITTED_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for OmittedKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for OmittedKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = OmittedKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(OmittedKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for OmittedKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for OmittedKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::OMITTED_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::OMITTED_KIND_EVENT), + 2i32 => ::core::option::Option::Some(Self::OMITTED_KIND_ARTIFACT), + 3i32 => ::core::option::Option::Some(Self::OMITTED_KIND_CHECKPOINT), + 4i32 => ::core::option::Option::Some(Self::OMITTED_KIND_CHILD_SESSION), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::OMITTED_KIND_UNSPECIFIED => "OMITTED_KIND_UNSPECIFIED", + Self::OMITTED_KIND_EVENT => "OMITTED_KIND_EVENT", + Self::OMITTED_KIND_ARTIFACT => "OMITTED_KIND_ARTIFACT", + Self::OMITTED_KIND_CHECKPOINT => "OMITTED_KIND_CHECKPOINT", + Self::OMITTED_KIND_CHILD_SESSION => "OMITTED_KIND_CHILD_SESSION", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "OMITTED_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::OMITTED_KIND_UNSPECIFIED) + } + "OMITTED_KIND_EVENT" => { + ::core::option::Option::Some(Self::OMITTED_KIND_EVENT) + } + "OMITTED_KIND_ARTIFACT" => { + ::core::option::Option::Some(Self::OMITTED_KIND_ARTIFACT) + } + "OMITTED_KIND_CHECKPOINT" => { + ::core::option::Option::Some(Self::OMITTED_KIND_CHECKPOINT) + } + "OMITTED_KIND_CHILD_SESSION" => { + ::core::option::Option::Some(Self::OMITTED_KIND_CHILD_SESSION) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::OMITTED_KIND_UNSPECIFIED, + Self::OMITTED_KIND_EVENT, + Self::OMITTED_KIND_ARTIFACT, + Self::OMITTED_KIND_CHECKPOINT, + Self::OMITTED_KIND_CHILD_SESSION, + ] + } +} +/// OmissionReason is why it was lost. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum OmissionReason { + OMISSION_REASON_UNSPECIFIED = 0i32, + /// Present in the source and did not decode. + OMISSION_REASON_UNDECODABLE = 1i32, + /// Referenced by the source and not there. + OMISSION_REASON_MISSING = 2i32, + /// Present, and its content did not match its recorded digest. Deliberately + /// never carried: a salvage that copied content failing its own integrity + /// check would launder corruption into a session that looks healthy. + OMISSION_REASON_DIGEST_MISMATCH = 3i32, + /// Present and could not be read well enough to verify. Not the same as + /// absent, and not evidence of corruption, matching the doctor's three-way + /// artifact observation. + OMISSION_REASON_UNVERIFIABLE = 4i32, + /// Erased under a privacy obligation. It was not lost, and a salvage must not + /// resurrect it. Recorded so the gap in the salvaged history is explained + /// rather than read as further damage. + OMISSION_REASON_ERASED = 5i32, +} +impl OmissionReason { + ///Idiomatic alias for [`Self::OMISSION_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::OMISSION_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::OMISSION_REASON_UNDECODABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Undecodable: Self = Self::OMISSION_REASON_UNDECODABLE; + ///Idiomatic alias for [`Self::OMISSION_REASON_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Missing: Self = Self::OMISSION_REASON_MISSING; + ///Idiomatic alias for [`Self::OMISSION_REASON_DIGEST_MISMATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DigestMismatch: Self = Self::OMISSION_REASON_DIGEST_MISMATCH; + ///Idiomatic alias for [`Self::OMISSION_REASON_UNVERIFIABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unverifiable: Self = Self::OMISSION_REASON_UNVERIFIABLE; + ///Idiomatic alias for [`Self::OMISSION_REASON_ERASED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Erased: Self = Self::OMISSION_REASON_ERASED; +} +impl ::core::default::Default for OmissionReason { + fn default() -> Self { + Self::OMISSION_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for OmissionReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for OmissionReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = OmissionReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(OmissionReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for OmissionReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for OmissionReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::OMISSION_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::OMISSION_REASON_UNDECODABLE), + 2i32 => ::core::option::Option::Some(Self::OMISSION_REASON_MISSING), + 3i32 => ::core::option::Option::Some(Self::OMISSION_REASON_DIGEST_MISMATCH), + 4i32 => ::core::option::Option::Some(Self::OMISSION_REASON_UNVERIFIABLE), + 5i32 => ::core::option::Option::Some(Self::OMISSION_REASON_ERASED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::OMISSION_REASON_UNSPECIFIED => "OMISSION_REASON_UNSPECIFIED", + Self::OMISSION_REASON_UNDECODABLE => "OMISSION_REASON_UNDECODABLE", + Self::OMISSION_REASON_MISSING => "OMISSION_REASON_MISSING", + Self::OMISSION_REASON_DIGEST_MISMATCH => "OMISSION_REASON_DIGEST_MISMATCH", + Self::OMISSION_REASON_UNVERIFIABLE => "OMISSION_REASON_UNVERIFIABLE", + Self::OMISSION_REASON_ERASED => "OMISSION_REASON_ERASED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "OMISSION_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::OMISSION_REASON_UNSPECIFIED) + } + "OMISSION_REASON_UNDECODABLE" => { + ::core::option::Option::Some(Self::OMISSION_REASON_UNDECODABLE) + } + "OMISSION_REASON_MISSING" => { + ::core::option::Option::Some(Self::OMISSION_REASON_MISSING) + } + "OMISSION_REASON_DIGEST_MISMATCH" => { + ::core::option::Option::Some(Self::OMISSION_REASON_DIGEST_MISMATCH) + } + "OMISSION_REASON_UNVERIFIABLE" => { + ::core::option::Option::Some(Self::OMISSION_REASON_UNVERIFIABLE) + } + "OMISSION_REASON_ERASED" => { + ::core::option::Option::Some(Self::OMISSION_REASON_ERASED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::OMISSION_REASON_UNSPECIFIED, + Self::OMISSION_REASON_UNDECODABLE, + Self::OMISSION_REASON_MISSING, + Self::OMISSION_REASON_DIGEST_MISMATCH, + Self::OMISSION_REASON_UNVERIFIABLE, + Self::OMISSION_REASON_ERASED, + ] + } +} +/// SalvageResult is the disposition of one SalvageSession call. +/// +/// There is no separate "recovered with unverified artifacts" value, which is a +/// deliberate departure from the shape Fx uses. History completeness and +/// artifact verification are independent axes, and one flat enum forces the +/// server to choose which of the two facts to report. The omissions carry both, +/// and a second signal that could disagree with them would only invite a caller +/// to pick. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SalvageResult { + SALVAGE_RESULT_UNSPECIFIED = 0i32, + /// Every source event decoded and every referenced artifact verified. + SALVAGE_RESULT_COMPLETE = 1i32, + /// A session was produced and items are missing. They are enumerated. + SALVAGE_RESULT_PARTIAL = 2i32, + /// A prior attempt under this identity already produced the target session. + SALVAGE_RESULT_ALREADY_SALVAGED = 3i32, + /// Refused before writing. Carries a RefusalDetail. + SALVAGE_RESULT_REFUSED = 4i32, + /// The outcome could not be classified. + SALVAGE_RESULT_INDETERMINATE = 5i32, + /// PLAN_ONLY: a salvage would run and nothing was written. The planned + /// omissions are on the record, so an operator can see what would be lost + /// before deciding. + SALVAGE_RESULT_WOULD_SALVAGE = 6i32, +} +impl SalvageResult { + ///Idiomatic alias for [`Self::SALVAGE_RESULT_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SALVAGE_RESULT_UNSPECIFIED; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_COMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Complete: Self = Self::SALVAGE_RESULT_COMPLETE; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_PARTIAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Partial: Self = Self::SALVAGE_RESULT_PARTIAL; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_ALREADY_SALVAGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AlreadySalvaged: Self = Self::SALVAGE_RESULT_ALREADY_SALVAGED; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_REFUSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Refused: Self = Self::SALVAGE_RESULT_REFUSED; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_INDETERMINATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Indeterminate: Self = Self::SALVAGE_RESULT_INDETERMINATE; + ///Idiomatic alias for [`Self::SALVAGE_RESULT_WOULD_SALVAGE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const WouldSalvage: Self = Self::SALVAGE_RESULT_WOULD_SALVAGE; +} +impl ::core::default::Default for SalvageResult { + fn default() -> Self { + Self::SALVAGE_RESULT_UNSPECIFIED + } +} +impl ::serde::Serialize for SalvageResult { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SalvageResult { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SalvageResult; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(SalvageResult)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageResult { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SalvageResult { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_COMPLETE), + 2i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_PARTIAL), + 3i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_ALREADY_SALVAGED), + 4i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_REFUSED), + 5i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_INDETERMINATE), + 6i32 => ::core::option::Option::Some(Self::SALVAGE_RESULT_WOULD_SALVAGE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SALVAGE_RESULT_UNSPECIFIED => "SALVAGE_RESULT_UNSPECIFIED", + Self::SALVAGE_RESULT_COMPLETE => "SALVAGE_RESULT_COMPLETE", + Self::SALVAGE_RESULT_PARTIAL => "SALVAGE_RESULT_PARTIAL", + Self::SALVAGE_RESULT_ALREADY_SALVAGED => "SALVAGE_RESULT_ALREADY_SALVAGED", + Self::SALVAGE_RESULT_REFUSED => "SALVAGE_RESULT_REFUSED", + Self::SALVAGE_RESULT_INDETERMINATE => "SALVAGE_RESULT_INDETERMINATE", + Self::SALVAGE_RESULT_WOULD_SALVAGE => "SALVAGE_RESULT_WOULD_SALVAGE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SALVAGE_RESULT_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_UNSPECIFIED) + } + "SALVAGE_RESULT_COMPLETE" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_COMPLETE) + } + "SALVAGE_RESULT_PARTIAL" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_PARTIAL) + } + "SALVAGE_RESULT_ALREADY_SALVAGED" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_ALREADY_SALVAGED) + } + "SALVAGE_RESULT_REFUSED" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_REFUSED) + } + "SALVAGE_RESULT_INDETERMINATE" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_INDETERMINATE) + } + "SALVAGE_RESULT_WOULD_SALVAGE" => { + ::core::option::Option::Some(Self::SALVAGE_RESULT_WOULD_SALVAGE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SALVAGE_RESULT_UNSPECIFIED, + Self::SALVAGE_RESULT_COMPLETE, + Self::SALVAGE_RESULT_PARTIAL, + Self::SALVAGE_RESULT_ALREADY_SALVAGED, + Self::SALVAGE_RESULT_REFUSED, + Self::SALVAGE_RESULT_INDETERMINATE, + Self::SALVAGE_RESULT_WOULD_SALVAGE, + ] + } +} +/// RefusalReason is the specific refusal. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RefusalReason { + REFUSAL_REASON_UNSPECIFIED = 0i32, + REFUSAL_REASON_SOURCE_NOT_FOUND = 1i32, + /// Event order could not be established, so any session produced would be a + /// plausible-looking transcript in an order that never happened. + REFUSAL_REASON_ORDER_UNPROVEN = 2i32, + /// Nothing in the source could be read. An empty salvaged session would be a + /// new artifact claiming provenance it cannot support. + REFUSAL_REASON_NOTHING_RECOVERABLE = 3i32, + /// The source exceeds the limits allowed for one operation. + REFUSAL_REASON_SIZE_LIMIT = 4i32, + /// A stream already exists at the derived target id and is not the target this + /// identity would have produced. + REFUSAL_REASON_TARGET_DIVERGED = 5i32, + /// Another maintenance operation holds this session. + REFUSAL_REASON_OPERATION_IN_PROGRESS = 6i32, +} +impl RefusalReason { + ///Idiomatic alias for [`Self::REFUSAL_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::REFUSAL_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::REFUSAL_REASON_SOURCE_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SourceNotFound: Self = Self::REFUSAL_REASON_SOURCE_NOT_FOUND; + ///Idiomatic alias for [`Self::REFUSAL_REASON_ORDER_UNPROVEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OrderUnproven: Self = Self::REFUSAL_REASON_ORDER_UNPROVEN; + ///Idiomatic alias for [`Self::REFUSAL_REASON_NOTHING_RECOVERABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NothingRecoverable: Self = Self::REFUSAL_REASON_NOTHING_RECOVERABLE; + ///Idiomatic alias for [`Self::REFUSAL_REASON_SIZE_LIMIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SizeLimit: Self = Self::REFUSAL_REASON_SIZE_LIMIT; + ///Idiomatic alias for [`Self::REFUSAL_REASON_TARGET_DIVERGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const TargetDiverged: Self = Self::REFUSAL_REASON_TARGET_DIVERGED; + ///Idiomatic alias for [`Self::REFUSAL_REASON_OPERATION_IN_PROGRESS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OperationInProgress: Self = Self::REFUSAL_REASON_OPERATION_IN_PROGRESS; +} +impl ::core::default::Default for RefusalReason { + fn default() -> Self { + Self::REFUSAL_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for RefusalReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RefusalReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RefusalReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(RefusalReason)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RefusalReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RefusalReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::REFUSAL_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::REFUSAL_REASON_SOURCE_NOT_FOUND), + 2i32 => ::core::option::Option::Some(Self::REFUSAL_REASON_ORDER_UNPROVEN), + 3i32 => { + ::core::option::Option::Some(Self::REFUSAL_REASON_NOTHING_RECOVERABLE) + } + 4i32 => ::core::option::Option::Some(Self::REFUSAL_REASON_SIZE_LIMIT), + 5i32 => ::core::option::Option::Some(Self::REFUSAL_REASON_TARGET_DIVERGED), + 6i32 => { + ::core::option::Option::Some(Self::REFUSAL_REASON_OPERATION_IN_PROGRESS) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::REFUSAL_REASON_UNSPECIFIED => "REFUSAL_REASON_UNSPECIFIED", + Self::REFUSAL_REASON_SOURCE_NOT_FOUND => "REFUSAL_REASON_SOURCE_NOT_FOUND", + Self::REFUSAL_REASON_ORDER_UNPROVEN => "REFUSAL_REASON_ORDER_UNPROVEN", + Self::REFUSAL_REASON_NOTHING_RECOVERABLE => { + "REFUSAL_REASON_NOTHING_RECOVERABLE" + } + Self::REFUSAL_REASON_SIZE_LIMIT => "REFUSAL_REASON_SIZE_LIMIT", + Self::REFUSAL_REASON_TARGET_DIVERGED => "REFUSAL_REASON_TARGET_DIVERGED", + Self::REFUSAL_REASON_OPERATION_IN_PROGRESS => { + "REFUSAL_REASON_OPERATION_IN_PROGRESS" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "REFUSAL_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_UNSPECIFIED) + } + "REFUSAL_REASON_SOURCE_NOT_FOUND" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_SOURCE_NOT_FOUND) + } + "REFUSAL_REASON_ORDER_UNPROVEN" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_ORDER_UNPROVEN) + } + "REFUSAL_REASON_NOTHING_RECOVERABLE" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_NOTHING_RECOVERABLE) + } + "REFUSAL_REASON_SIZE_LIMIT" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_SIZE_LIMIT) + } + "REFUSAL_REASON_TARGET_DIVERGED" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_TARGET_DIVERGED) + } + "REFUSAL_REASON_OPERATION_IN_PROGRESS" => { + ::core::option::Option::Some(Self::REFUSAL_REASON_OPERATION_IN_PROGRESS) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::REFUSAL_REASON_UNSPECIFIED, + Self::REFUSAL_REASON_SOURCE_NOT_FOUND, + Self::REFUSAL_REASON_ORDER_UNPROVEN, + Self::REFUSAL_REASON_NOTHING_RECOVERABLE, + Self::REFUSAL_REASON_SIZE_LIMIT, + Self::REFUSAL_REASON_TARGET_DIVERGED, + Self::REFUSAL_REASON_OPERATION_IN_PROGRESS, + ] + } +} +/// The durable record of a Session salvage. +/// +/// A salvage copies what can be read from a damaged session into a new session +/// identity. It is the opposite of a migration on every axis that matters: +/// +/// | | migration | salvage | +/// | identity | preserved | new | +/// | ordinals | preserved exactly | not preserved | +/// | source | must be intact | is damaged | +/// | source after | replaced | untouched | +/// | loss | inadmissible | expected and enumerated | +/// +/// It is also not ForkSession. A fork inherits a prefix it assumes is valid and +/// references it in place, so the source must stay readable forever. A salvage +/// exists because the source's validity is incomplete, so it copies, and the +/// copy is a different session that must never be presented as the original. +/// +/// SalvageIdentity is the retry identity of a salvage. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageIdentity { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// Chosen by the operator or orchestrator. Two salvages of one damaged source + /// are legitimately different operations, so identity cannot be derived from + /// the source alone. + /// + /// Field 2: `salvage_key` + #[serde( + rename = "salvageKey", + alias = "salvage_key", + with = "::buffa::json_helpers::proto_string" + )] + pub salvage_key: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for SalvageIdentity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageIdentity") + .field("source_session_id", &self.source_session_id) + .field("salvage_key", &self.salvage_key) + .finish() + } +} +impl SalvageIdentity { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity"; +} +::buffa::impl_default_instance!(SalvageIdentity); +impl ::buffa::MessageName for SalvageIdentity { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageIdentity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity"; +} +impl ::buffa::Message for SalvageIdentity { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_string_field(2u32, &self.salvage_key, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.salvage_key, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.salvage_key.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageIdentity { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_IDENTITY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIdentity", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SalvageIntent is written durably before the target session is created. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageIntent { + /// Field 1: `identity` + #[serde(rename = "identity")] + pub identity: ::buffa::MessageField< + SalvageIdentity, + ::buffa::Inline, + >, + /// Field 2: `source` + #[serde(rename = "source")] + pub source: ::buffa::MessageField>, + /// The id the salvaged session will have, derived from the identity before any + /// write is attempted. + /// + /// Deriving it is what makes a retry safe. The salvaged session is created by + /// an atomic batch under a NoStream precondition, so a retry that lands on the + /// same id sees a visible conflict instead of producing a second copy. A + /// randomly minted id would leave a retry unable to find its own prior work, + /// which is the same trap the migration reconciler exists to escape, closed + /// here by the write precondition rather than by a later comparison. + /// + /// Field 3: `target_session_id` + #[serde( + rename = "targetSessionId", + alias = "target_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub target_session_id: ::buffa::alloc::string::String, + /// Field 4: `order_proof` + #[serde( + rename = "orderProof", + alias = "order_proof", + with = "::buffa::json_helpers::proto_enum" + )] + pub order_proof: ::buffa::EnumValue, + /// Field 5: `actor` + #[serde(rename = "actor", with = "::buffa::json_helpers::proto_string")] + pub actor: ::buffa::alloc::string::String, + /// Field 6: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_string")] + pub reason: ::buffa::alloc::string::String, + /// Field 7: `planned_at` + #[serde(rename = "plannedAt", alias = "planned_at")] + pub planned_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for SalvageIntent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageIntent") + .field("identity", &self.identity) + .field("source", &self.source) + .field("target_session_id", &self.target_session_id) + .field("order_proof", &self.order_proof) + .field("actor", &self.actor) + .field("reason", &self.reason) + .field("planned_at", &self.planned_at) + .finish() + } +} +impl SalvageIntent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent"; +} +::buffa::impl_default_instance!(SalvageIntent); +impl ::buffa::MessageName for SalvageIntent { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent"; +} +impl ::buffa::Message for SalvageIntent { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.identity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.identity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.target_session_id) as u64; + { + let val = self.order_proof.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if self.planned_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.planned_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.identity.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.identity.write_to(__cache, buf); + } + if self.source.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.target_session_id, buf); + ::buffa::types::put_int32_field(4u32, self.order_proof.to_i32(), buf); + ::buffa::types::put_string_field(5u32, &self.actor, buf); + ::buffa::types::put_string_field(6u32, &self.reason, buf); + if self.planned_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.planned_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.identity.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.target_session_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.order_proof = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.actor, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.reason, buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.planned_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.identity = ::buffa::MessageField::none(); + self.source = ::buffa::MessageField::none(); + self.target_session_id.clear(); + self.order_proof = ::buffa::EnumValue::from(0); + self.actor.clear(); + self.reason.clear(); + self.planned_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageIntent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_INTENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageIntent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SalvageRecord is the intent plus everything learned since. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageRecord { + /// Field 1: `intent` + #[serde(rename = "intent")] + pub intent: ::buffa::MessageField>, + /// Field 2: `state` + #[serde(rename = "state", with = "::buffa::json_helpers::proto_enum")] + pub state: ::buffa::EnumValue, + /// Set only for MAINTENANCE_STATE_INDETERMINATE. + /// + /// Field 3: `indeterminate` + #[serde( + rename = "indeterminate", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub indeterminate: ::buffa::MessageField< + IndeterminateDetail, + ::buffa::Inline, + >, + /// Everything the source held that the salvaged session does not. + /// + /// Field 4: `omitted` + #[serde( + rename = "omitted", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub omitted: ::buffa::alloc::vec::Vec, + /// Field 5: `attempt_count` + #[serde( + rename = "attemptCount", + alias = "attempt_count", + with = "::buffa::json_helpers::uint32" + )] + pub attempt_count: u32, + /// Field 6: `updated_at` + #[serde(rename = "updatedAt", alias = "updated_at")] + pub updated_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for SalvageRecord { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageRecord") + .field("intent", &self.intent) + .field("state", &self.state) + .field("indeterminate", &self.indeterminate) + .field("omitted", &self.omitted) + .field("attempt_count", &self.attempt_count) + .field("updated_at", &self.updated_at) + .finish() + } +} +impl SalvageRecord { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord"; +} +::buffa::impl_default_instance!(SalvageRecord); +impl ::buffa::MessageName for SalvageRecord { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord"; +} +impl ::buffa::Message for SalvageRecord { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.omitted { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.updated_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.updated_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.intent.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intent.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.state.to_i32(), buf); + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + for v in &self.omitted { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.attempt_count, buf); + if self.updated_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.updated_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.intent.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.indeterminate.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.omitted.push(elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.attempt_count = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.updated_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.intent = ::buffa::MessageField::none(); + self.state = ::buffa::EnumValue::from(0); + self.indeterminate = ::buffa::MessageField::none(); + self.omitted.clear(); + self.attempt_count = 0u32; + self.updated_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageRecord { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_RECORD_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageRecord", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// OmittedItem is one thing the salvage could not carry. +/// +/// Enumerated rather than counted. An operator told that three things were lost +/// cannot tell whether they were three tool results or three user messages, and +/// that difference decides whether the salvaged session is worth keeping. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct OmittedItem { + /// Field 1: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// The source position, for an omission that had one. + /// + /// Field 2: `source_ordinal` + #[serde( + rename = "sourceOrdinal", + alias = "source_ordinal", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub source_ordinal: ::core::option::Option, + /// The artifact, checkpoint, or child session id, for an omission that had one. + /// + /// Field 3: `entity_id` + #[serde( + rename = "entityId", + alias = "entity_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub entity_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for OmittedItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OmittedItem") + .field("kind", &self.kind) + .field("source_ordinal", &self.source_ordinal) + .field("entity_id", &self.entity_id) + .field("reason", &self.reason) + .finish() + } +} +impl OmittedItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.OmittedItem"; +} +impl OmittedItem { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::source_ordinal`] to `Some(value)`, consuming and returning `self`. + pub fn with_source_ordinal(mut self, value: u64) -> Self { + self.source_ordinal = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::entity_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_entity_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.entity_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(OmittedItem); +impl ::buffa::MessageName for OmittedItem { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "OmittedItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.OmittedItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.OmittedItem"; +} +impl ::buffa::Message for OmittedItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.source_ordinal { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.entity_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if let Some(v) = self.source_ordinal { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(ref v) = self.entity_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_int32_field(4u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source_ordinal = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .entity_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.source_ordinal = ::core::option::Option::None; + self.entity_id = ::core::option::Option::None; + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for OmittedItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OMITTED_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.OmittedItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RefusalDetail is why a salvage wrote nothing. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RefusalDetail { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 2: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for RefusalDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RefusalDetail") + .field("reason", &self.reason) + .field("detail", &self.detail) + .finish() + } +} +impl RefusalDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail"; +} +impl RefusalDetail { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RefusalDetail); +impl ::buffa::MessageName for RefusalDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "RefusalDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail"; +} +impl ::buffa::Message for RefusalDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(2u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RefusalDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REFUSAL_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.RefusalDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.__view.rs new file mode 100644 index 0000000000..99757981f2 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.__view.rs @@ -0,0 +1,1361 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/salvage_session.proto + +/// SalvageSession copies what can be read from a damaged session into a new +/// session identity, leaving the source untouched. +/// +/// Ordering of effects matches the migration and for the same reason: record the +/// intent, stage the copied artifacts, create the target session as one atomic +/// batch, validate. The source is never written to at any point, so a salvage +/// that fails halfway costs a partially staged target and nothing else. +#[derive(Clone, Debug, Default)] +pub struct SalvageSessionRequestView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// Distinguishes this salvage from another salvage of the same source, and is + /// what the target session id is derived from. A caller retrying a salvage + /// must reuse it; a caller wanting a second, independent salvage must not. + /// + /// Field 2: `salvage_key` + pub salvage_key: &'a str, + /// Field 3: `actor` + pub actor: &'a str, + /// Field 4: `reason` + pub reason: &'a str, + /// Unset is PLAN_ONLY. + /// + /// Field 5: `mode` + pub mode: ::core::option::Option<::buffa::EnumValue>, + /// Workspace for the salvaged session. Needed only when the source's own + /// workspace could not be read, which is exactly the case a damaged source + /// makes likely. + /// + /// Field 6: `workspace_id` + pub workspace_id: ::core::option::Option<&'a str>, + /// Field 7: `limits` + pub limits: ::buffa::MessageFieldView< + super::super::__buffa::view::SalvageLimitsView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SalvageSessionRequestView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `salvage_key` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_salvage_key(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `actor` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_actor(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SalvageSessionRequestView<'a> { + type Owned = super::super::SalvageSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.salvage_key = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.actor = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.mode = Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(&mut cur)?), + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.workspace_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.limits.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.limits = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::SalvageSessionRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::SalvageSessionRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageSessionRequest { + source_session_id: self.source_session_id.to_string(), + salvage_key: self.salvage_key.to_string(), + actor: self.actor.to_string(), + reason: self.reason.to_string(), + mode: self.mode, + workspace_id: self.workspace_id.map(|s| s.to_string()), + limits: match self.limits.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SalvageLimits, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if let Some(ref v) = self.mode { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.limits.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.limits.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_string_field(2u32, &self.salvage_key, buf); + ::buffa::types::put_string_field(3u32, &self.actor, buf); + ::buffa::types::put_string_field(4u32, &self.reason, buf); + if let Some(ref v) = self.mode { + ::buffa::types::put_int32_field(5u32, v.to_i32(), buf); + } + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if self.limits.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.limits.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + __map.serialize_entry("salvageKey", self.salvage_key)?; + } + { + __map.serialize_entry("actor", self.actor)?; + } + { + __map.serialize_entry("reason", self.reason)?; + } + if let ::core::option::Option::Some(ref __v) = self.mode { + __map.serialize_entry("mode", __v)?; + } + if let ::core::option::Option::Some(__v) = self.workspace_id { + __map.serialize_entry("workspaceId", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.limits.as_option() { + __map.serialize_entry("limits", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest"; +} +::buffa::impl_default_view_instance!(SalvageSessionRequestView); +::buffa::impl_view_reborrow!(SalvageSessionRequestView); +/** Self-contained, `'static` owned view of a `SalvageSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl SalvageSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// Distinguishes this salvage from another salvage of the same source, and is + /// what the target session id is derived from. A caller retrying a salvage + /// must reuse it; a caller wanting a second, independent salvage must not. + /// + /// Field 2: `salvage_key` + #[must_use] + pub fn salvage_key(&self) -> &'_ str { + self.0.reborrow().salvage_key + } + /// Field 3: `actor` + #[must_use] + pub fn actor(&self) -> &'_ str { + self.0.reborrow().actor + } + /// Field 4: `reason` + #[must_use] + pub fn reason(&self) -> &'_ str { + self.0.reborrow().reason + } + /// Unset is PLAN_ONLY. + /// + /// Field 5: `mode` + #[must_use] + pub fn mode( + &self, + ) -> ::core::option::Option<::buffa::EnumValue> { + self.0.reborrow().mode + } + /// Workspace for the salvaged session. Needed only when the source's own + /// workspace could not be read, which is exactly the case a damaged source + /// makes likely. + /// + /// Field 6: `workspace_id` + #[must_use] + pub fn workspace_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().workspace_id + } + /// Field 7: `limits` + #[must_use] + pub fn limits( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().limits + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageSessionRequest { + type View<'a> = SalvageSessionRequestView<'a>; + type ViewHandle = SalvageSessionRequestOwnedView; +} +impl ::serde::Serialize for SalvageSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SalvageLimits bounds one call. +#[derive(Clone, Debug, Default)] +pub struct SalvageLimitsView<'a> { + /// Field 1: `max_source_events` + pub max_source_events: ::core::option::Option, + /// Field 2: `max_source_bytes` + pub max_source_bytes: ::core::option::Option, + /// Field 3: `max_artifacts_verified` + pub max_artifacts_verified: ::core::option::Option, + /// Field 4: `max_duration` + pub max_duration: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, +} +impl<'a> ::buffa::MessageView<'a> for SalvageLimitsView<'a> { + type Owned = super::super::SalvageLimits; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_source_events = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_source_bytes = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.max_artifacts_verified = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.max_duration.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.max_duration = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageLimits { + max_source_events: self.max_source_events, + max_source_bytes: self.max_source_bytes, + max_artifacts_verified: self.max_artifacts_verified, + max_duration: match self.max_duration.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageLimitsView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_source_events { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_source_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_artifacts_verified { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_source_events { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_source_bytes { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(v) = self.max_artifacts_verified { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageLimitsView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(__v) = self.max_source_events { + __map + .serialize_entry( + "maxSourceEvents", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.max_source_bytes { + __map + .serialize_entry( + "maxSourceBytes", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.max_artifacts_verified { + __map + .serialize_entry( + "maxArtifactsVerified", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.max_duration.as_option() { + __map.serialize_entry("maxDuration", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageLimitsView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageLimits"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits"; +} +::buffa::impl_default_view_instance!(SalvageLimitsView); +::buffa::impl_view_reborrow!(SalvageLimitsView); +/** Self-contained, `'static` owned view of a `SalvageLimits` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageLimitsView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageLimitsView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageLimitsOwnedView(::buffa::OwnedView>); +impl SalvageLimitsOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageLimitsOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageLimitsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageLimits, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageLimitsOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageLimitsView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageLimitsView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageLimits { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `max_source_events` + #[must_use] + pub fn max_source_events(&self) -> ::core::option::Option { + self.0.reborrow().max_source_events + } + /// Field 2: `max_source_bytes` + #[must_use] + pub fn max_source_bytes(&self) -> ::core::option::Option { + self.0.reborrow().max_source_bytes + } + /// Field 3: `max_artifacts_verified` + #[must_use] + pub fn max_artifacts_verified(&self) -> ::core::option::Option { + self.0.reborrow().max_artifacts_verified + } + /// Field 4: `max_duration` + #[must_use] + pub fn max_duration( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().max_duration + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageLimitsOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageLimitsOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageLimitsOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageLimitsOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageLimits { + type View<'a> = SalvageLimitsView<'a>; + type ViewHandle = SalvageLimitsOwnedView; +} +impl ::serde::Serialize for SalvageLimitsOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct SalvageSessionResponseView<'a> { + /// Field 1: `result` + pub result: ::buffa::EnumValue, + /// Always present, including on refusal. + /// + /// Field 2: `record` + pub record: ::buffa::MessageFieldView< + super::super::__buffa::view::SalvageRecordView<'a>, + >, + /// The derived id, present even when nothing was written, so a caller can find + /// the target of a call whose response it never received. + /// + /// Field 3: `target_session_id` + pub target_session_id: &'a str, + /// Set only for SALVAGE_RESULT_REFUSED. + /// + /// Field 4: `refused` + pub refused: ::buffa::MessageFieldView< + super::super::__buffa::view::RefusalDetailView<'a>, + >, + /// Field 5: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SalvageSessionResponseView<'a> { + /**Whether required field `result` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_result(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `record` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_record(&self) -> bool { + self.record.is_set() + } + /**Whether required field `target_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_target_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SalvageSessionResponseView<'a> { + type Owned = super::super::SalvageSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.record.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.record = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.target_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.refused.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.refused = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::SalvageSessionResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::SalvageSessionResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SalvageSessionResponse { + result: self.result, + record: match self.record.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SalvageRecord, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + target_session_id: self.target_session_id.to_string(), + refused: match self.refused.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::RefusalDetail, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SalvageSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.target_session_id) as u64; + if self.refused.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.refused.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.target_session_id, buf); + if self.refused.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.refused.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SalvageSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("result", &self.result)?; + } + { + if let ::core::option::Option::Some(__v) = self.record.as_option() { + __map.serialize_entry("record", __v)?; + } + } + { + __map.serialize_entry("targetSessionId", self.target_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.refused.as_option() { + __map.serialize_entry("refused", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SalvageSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse"; +} +::buffa::impl_default_view_instance!(SalvageSessionResponseView); +::buffa::impl_view_reborrow!(SalvageSessionResponseView); +/** Self-contained, `'static` owned view of a `SalvageSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`SalvageSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SalvageSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SalvageSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl SalvageSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SalvageSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SalvageSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SalvageSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SalvageSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SalvageSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `result` + #[must_use] + pub fn result(&self) -> ::buffa::EnumValue { + self.0.reborrow().result + } + /// Always present, including on refusal. + /// + /// Field 2: `record` + #[must_use] + pub fn record( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().record + } + /// The derived id, present even when nothing was written, so a caller can find + /// the target of a call whose response it never received. + /// + /// Field 3: `target_session_id` + #[must_use] + pub fn target_session_id(&self) -> &'_ str { + self.0.reborrow().target_session_id + } + /// Set only for SALVAGE_RESULT_REFUSED. + /// + /// Field 4: `refused` + #[must_use] + pub fn refused( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().refused + } + /// Field 5: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SalvageSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SalvageSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SalvageSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SalvageSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SalvageSessionResponse { + type View<'a> = SalvageSessionResponseView<'a>; + type ViewHandle = SalvageSessionResponseOwnedView; +} +impl ::serde::Serialize for SalvageSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.rs new file mode 100644 index 0000000000..f5578c7d6e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.salvage_session.rs @@ -0,0 +1,894 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/salvage_session.proto + +/// SalvageMode is whether this call may write. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SalvageMode { + SALVAGE_MODE_UNSPECIFIED = 0i32, + /// Read the source, decide what would be carried, write nothing. + SALVAGE_MODE_PLAN_ONLY = 1i32, + SALVAGE_MODE_COMMIT = 2i32, +} +impl SalvageMode { + ///Idiomatic alias for [`Self::SALVAGE_MODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SALVAGE_MODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::SALVAGE_MODE_PLAN_ONLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PlanOnly: Self = Self::SALVAGE_MODE_PLAN_ONLY; + ///Idiomatic alias for [`Self::SALVAGE_MODE_COMMIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Commit: Self = Self::SALVAGE_MODE_COMMIT; +} +impl ::core::default::Default for SalvageMode { + fn default() -> Self { + Self::SALVAGE_MODE_UNSPECIFIED + } +} +impl ::serde::Serialize for SalvageMode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SalvageMode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SalvageMode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(SalvageMode)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageMode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SalvageMode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SALVAGE_MODE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SALVAGE_MODE_PLAN_ONLY), + 2i32 => ::core::option::Option::Some(Self::SALVAGE_MODE_COMMIT), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SALVAGE_MODE_UNSPECIFIED => "SALVAGE_MODE_UNSPECIFIED", + Self::SALVAGE_MODE_PLAN_ONLY => "SALVAGE_MODE_PLAN_ONLY", + Self::SALVAGE_MODE_COMMIT => "SALVAGE_MODE_COMMIT", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SALVAGE_MODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SALVAGE_MODE_UNSPECIFIED) + } + "SALVAGE_MODE_PLAN_ONLY" => { + ::core::option::Option::Some(Self::SALVAGE_MODE_PLAN_ONLY) + } + "SALVAGE_MODE_COMMIT" => { + ::core::option::Option::Some(Self::SALVAGE_MODE_COMMIT) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SALVAGE_MODE_UNSPECIFIED, + Self::SALVAGE_MODE_PLAN_ONLY, + Self::SALVAGE_MODE_COMMIT, + ] + } +} +/// SalvageSession copies what can be read from a damaged session into a new +/// session identity, leaving the source untouched. +/// +/// Ordering of effects matches the migration and for the same reason: record the +/// intent, stage the copied artifacts, create the target session as one atomic +/// batch, validate. The source is never written to at any point, so a salvage +/// that fails halfway costs a partially staged target and nothing else. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageSessionRequest { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// Distinguishes this salvage from another salvage of the same source, and is + /// what the target session id is derived from. A caller retrying a salvage + /// must reuse it; a caller wanting a second, independent salvage must not. + /// + /// Field 2: `salvage_key` + #[serde( + rename = "salvageKey", + alias = "salvage_key", + with = "::buffa::json_helpers::proto_string" + )] + pub salvage_key: ::buffa::alloc::string::String, + /// Field 3: `actor` + #[serde(rename = "actor", with = "::buffa::json_helpers::proto_string")] + pub actor: ::buffa::alloc::string::String, + /// Field 4: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_string")] + pub reason: ::buffa::alloc::string::String, + /// Unset is PLAN_ONLY. + /// + /// Field 5: `mode` + #[serde( + rename = "mode", + with = "::buffa::json_helpers::opt_enum", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub mode: ::core::option::Option<::buffa::EnumValue>, + /// Workspace for the salvaged session. Needed only when the source's own + /// workspace could not be read, which is exactly the case a damaged source + /// makes likely. + /// + /// Field 6: `workspace_id` + #[serde( + rename = "workspaceId", + alias = "workspace_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub workspace_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 7: `limits` + #[serde( + rename = "limits", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub limits: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for SalvageSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageSessionRequest") + .field("source_session_id", &self.source_session_id) + .field("salvage_key", &self.salvage_key) + .field("actor", &self.actor) + .field("reason", &self.reason) + .field("mode", &self.mode) + .field("workspace_id", &self.workspace_id) + .field("limits", &self.limits) + .finish() + } +} +impl SalvageSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest"; +} +impl SalvageSessionRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::mode`] to `Some(value)`, consuming and returning `self`. + pub fn with_mode( + mut self, + value: impl Into<::buffa::EnumValue>, + ) -> Self { + self.mode = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::workspace_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_workspace_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.workspace_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(SalvageSessionRequest); +impl ::buffa::MessageName for SalvageSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest"; +} +impl ::buffa::Message for SalvageSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.actor) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.reason) as u64; + if let Some(ref v) = self.mode { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.limits.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.limits.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_string_field(2u32, &self.salvage_key, buf); + ::buffa::types::put_string_field(3u32, &self.actor, buf); + ::buffa::types::put_string_field(4u32, &self.reason, buf); + if let Some(ref v) = self.mode { + ::buffa::types::put_int32_field(5u32, v.to_i32(), buf); + } + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if self.limits.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.limits.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.salvage_key, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.actor, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.reason, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.mode = ::core::option::Option::Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .workspace_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.limits.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.salvage_key.clear(); + self.actor.clear(); + self.reason.clear(); + self.mode = ::core::option::Option::None; + self.workspace_id = ::core::option::Option::None; + self.limits = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SalvageLimits bounds one call. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageLimits { + /// Field 1: `max_source_events` + #[serde( + rename = "maxSourceEvents", + alias = "max_source_events", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_source_events: ::core::option::Option, + /// Field 2: `max_source_bytes` + #[serde( + rename = "maxSourceBytes", + alias = "max_source_bytes", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_source_bytes: ::core::option::Option, + /// Field 3: `max_artifacts_verified` + #[serde( + rename = "maxArtifactsVerified", + alias = "max_artifacts_verified", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_artifacts_verified: ::core::option::Option, + /// Field 4: `max_duration` + #[serde( + rename = "maxDuration", + alias = "max_duration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub max_duration: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for SalvageLimits { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageLimits") + .field("max_source_events", &self.max_source_events) + .field("max_source_bytes", &self.max_source_bytes) + .field("max_artifacts_verified", &self.max_artifacts_verified) + .field("max_duration", &self.max_duration) + .finish() + } +} +impl SalvageLimits { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits"; +} +impl SalvageLimits { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_source_events`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_source_events(mut self, value: u64) -> Self { + self.max_source_events = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_source_bytes`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_source_bytes(mut self, value: u64) -> Self { + self.max_source_bytes = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_artifacts_verified`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_artifacts_verified(mut self, value: u64) -> Self { + self.max_artifacts_verified = Some(value); + self + } +} +::buffa::impl_default_instance!(SalvageLimits); +impl ::buffa::MessageName for SalvageLimits { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageLimits"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits"; +} +impl ::buffa::Message for SalvageLimits { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let Some(v) = self.max_source_events { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_source_bytes { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.max_artifacts_verified { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.max_duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let Some(v) = self.max_source_events { + ::buffa::types::put_uint64_field(1u32, v, buf); + } + if let Some(v) = self.max_source_bytes { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(v) = self.max_artifacts_verified { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + if self.max_duration.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_duration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_source_events = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_source_bytes = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.max_artifacts_verified = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.max_duration.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.max_source_events = ::core::option::Option::None; + self.max_source_bytes = ::core::option::Option::None; + self.max_artifacts_verified = ::core::option::Option::None; + self.max_duration = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageLimits { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_LIMITS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageLimits", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SalvageSessionResponse { + /// Field 1: `result` + #[serde(rename = "result", with = "::buffa::json_helpers::proto_enum")] + pub result: ::buffa::EnumValue, + /// Always present, including on refusal. + /// + /// Field 2: `record` + #[serde(rename = "record")] + pub record: ::buffa::MessageField>, + /// The derived id, present even when nothing was written, so a caller can find + /// the target of a call whose response it never received. + /// + /// Field 3: `target_session_id` + #[serde( + rename = "targetSessionId", + alias = "target_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub target_session_id: ::buffa::alloc::string::String, + /// Set only for SALVAGE_RESULT_REFUSED. + /// + /// Field 4: `refused` + #[serde( + rename = "refused", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub refused: ::buffa::MessageField>, + /// Field 5: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for SalvageSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SalvageSessionResponse") + .field("result", &self.result) + .field("record", &self.record) + .field("target_session_id", &self.target_session_id) + .field("refused", &self.refused) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl SalvageSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse"; +} +::buffa::impl_default_instance!(SalvageSessionResponse); +impl ::buffa::MessageName for SalvageSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "SalvageSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse"; +} +impl ::buffa::Message for SalvageSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.target_session_id) as u64; + if self.refused.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.refused.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.target_session_id, buf); + if self.refused.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.refused.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.record.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.target_session_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.refused.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.result = ::buffa::EnumValue::from(0); + self.record = ::buffa::MessageField::none(); + self.target_session_id.clear(); + self.refused = ::buffa::MessageField::none(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SalvageSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SALVAGE_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.SalvageSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.__view.rs new file mode 100644 index 0000000000..16728624cb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.__view.rs @@ -0,0 +1,708 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto + +/// Value types shared by the Session maintenance workflows: migration and +/// salvage. +/// +/// Redefined here rather than imported from the write side, following the rule +/// ADR#0035 facet 3 applies to the state, projections, and checkpoints subtrees. +/// A maintenance record outlives the schema it was written under -- that is the +/// entire point of migration provenance -- so it must not be pinned to a +/// write-side type that a migration is free to change. +/// +/// StreamBoundary names an exact cut of one session's own logical stream: how +/// far it extends and what the content at that extent is. +/// +/// Both workflows pin against one, and every indeterminate outcome is ultimately +/// the statement that an observed boundary did not match an expected one. +#[derive(Clone, Debug, Default)] +pub struct StreamBoundaryView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The 1-indexed SessionOrdinal of the last event in the cut. Fold-derived, + /// never a JetStream sequence, so it survives restore and relocation. + /// + /// Field 2: `ordinal` + pub ordinal: u64, + /// Field 3: `content_digest` + pub content_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::ContentDigestView<'a>, + >, + /// Which incarnation of the physical stream this cut was taken from: the + /// subject token that isolates one incarnation's subject space from the next, + /// per ADR#0059. Required, because an unset incarnation is not "the same + /// incarnation" and a comparison against one can never fail. + /// + /// A migration's source names the retiring incarnation and its expected target + /// names the new one. Two boundaries carrying different incarnations are not + /// comparable by ordinal, and treating them as comparable is the failure + /// INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED exists to report. + /// + /// Field 4: `incarnation` + pub incarnation: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StreamBoundaryView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `content_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_content_digest(&self) -> bool { + self.content_digest.is_set() + } + /**Whether required field `incarnation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_incarnation(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StreamBoundaryView<'a> { + type Owned = super::super::StreamBoundary; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.content_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.content_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.incarnation = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StreamBoundary { + session_id: self.session_id.to_string(), + ordinal: self.ordinal, + content_digest: match self.content_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContentDigest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + incarnation: self.incarnation.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StreamBoundaryView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + if self.content_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.content_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.incarnation) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + if self.content_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.content_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.incarnation, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StreamBoundaryView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map + .serialize_entry( + "ordinal", + &::buffa::json_helpers::ProtoJson(&self.ordinal), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.content_digest.as_option() { + __map.serialize_entry("contentDigest", __v)?; + } + } + { + __map.serialize_entry("incarnation", self.incarnation)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StreamBoundaryView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "StreamBoundary"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary"; +} +::buffa::impl_default_view_instance!(StreamBoundaryView); +::buffa::impl_view_reborrow!(StreamBoundaryView); +/** Self-contained, `'static` owned view of a `StreamBoundary` message. + + Wraps [`::buffa::OwnedView`]`<`[`StreamBoundaryView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StreamBoundaryView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StreamBoundaryOwnedView(::buffa::OwnedView>); +impl StreamBoundaryOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StreamBoundaryOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StreamBoundaryOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StreamBoundary, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StreamBoundaryOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StreamBoundaryView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StreamBoundaryView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StreamBoundary { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The 1-indexed SessionOrdinal of the last event in the cut. Fold-derived, + /// never a JetStream sequence, so it survives restore and relocation. + /// + /// Field 2: `ordinal` + #[must_use] + pub fn ordinal(&self) -> u64 { + self.0.reborrow().ordinal + } + /// Field 3: `content_digest` + #[must_use] + pub fn content_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().content_digest + } + /// Which incarnation of the physical stream this cut was taken from: the + /// subject token that isolates one incarnation's subject space from the next, + /// per ADR#0059. Required, because an unset incarnation is not "the same + /// incarnation" and a comparison against one can never fail. + /// + /// A migration's source names the retiring incarnation and its expected target + /// names the new one. Two boundaries carrying different incarnations are not + /// comparable by ordinal, and treating them as comparable is the failure + /// INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED exists to report. + /// + /// Field 4: `incarnation` + #[must_use] + pub fn incarnation(&self) -> &'_ str { + self.0.reborrow().incarnation + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StreamBoundaryOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StreamBoundaryOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StreamBoundaryOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StreamBoundaryOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StreamBoundary { + type View<'a> = StreamBoundaryView<'a>; + type ViewHandle = StreamBoundaryOwnedView; +} +impl ::serde::Serialize for StreamBoundaryOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ContentDigest commits to the event bytes exactly as the log stores them. +/// +/// Never to a re-serialization. Protobuf encoding is not canonical, so a digest +/// taken over a decode-then-re-encode round trip would not reproduce, and a +/// workflow whose central check is "is this the same content" cannot be built on +/// a comparison that fails against bytes the system itself wrote. +#[derive(Clone, Debug, Default)] +pub struct ContentDigestView<'a> { + /// Field 1: `algorithm` + pub algorithm: &'a str, + /// Field 2: `value` + pub value: &'a [u8], + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ContentDigestView<'a> { + /**Whether required field `algorithm` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_algorithm(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `value` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_value(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ContentDigestView<'a> { + type Owned = super::super::ContentDigest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.algorithm = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.value = ::buffa::types::borrow_bytes(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ContentDigest { + algorithm: self.algorithm.to_string(), + value: (self.value).to_vec(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ContentDigestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.value) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.algorithm, buf); + ::buffa::types::put_shared_bytes_field(2u32, &self.value, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ContentDigestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("algorithm", self.algorithm)?; + } + { + __map + .serialize_entry( + "value", + &::buffa::json_helpers::BytesJson(self.value), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ContentDigestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ContentDigest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ContentDigest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ContentDigest"; +} +::buffa::impl_default_view_instance!(ContentDigestView); +::buffa::impl_view_reborrow!(ContentDigestView); +/** Self-contained, `'static` owned view of a `ContentDigest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ContentDigestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ContentDigestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ContentDigestOwnedView(::buffa::OwnedView>); +impl ContentDigestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentDigestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentDigestOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ContentDigest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentDigestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ContentDigestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ContentDigestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ContentDigest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `algorithm` + #[must_use] + pub fn algorithm(&self) -> &'_ str { + self.0.reborrow().algorithm + } + /// Field 2: `value` + #[must_use] + pub fn value(&self) -> &'_ [u8] { + self.0.reborrow().value + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ContentDigestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ContentDigestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ContentDigestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ContentDigestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ContentDigest { + type View<'a> = ContentDigestView<'a>; + type ViewHandle = ContentDigestOwnedView; +} +impl ::serde::Serialize for ContentDigestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.rs new file mode 100644 index 0000000000..054af39872 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.maintenance.v1alpha1.stream_boundary.rs @@ -0,0 +1,491 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/maintenance/v1alpha1/stream_boundary.proto + +/// OrderProof is how well the authoritative order of a source cut is known. +/// +/// A salvage that cannot establish order cannot produce a session, because a +/// transcript in the wrong order is worse than no transcript: it reads as +/// authoritative and is wrong. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum OrderProof { + ORDER_PROOF_UNSPECIFIED = 0i32, + /// Every position from 1 to the boundary is present and decoded. + ORDER_PROOF_CONTIGUOUS = 1i32, + /// Positions are missing, and every surviving event decoded and carries its + /// own position, so the relative order of what survives is known. The missing + /// positions are enumerated as omissions. + ORDER_PROOF_GAPPED = 2i32, + /// Order could not be established. Fail closed. + ORDER_PROOF_UNPROVEN = 3i32, +} +impl OrderProof { + ///Idiomatic alias for [`Self::ORDER_PROOF_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ORDER_PROOF_UNSPECIFIED; + ///Idiomatic alias for [`Self::ORDER_PROOF_CONTIGUOUS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Contiguous: Self = Self::ORDER_PROOF_CONTIGUOUS; + ///Idiomatic alias for [`Self::ORDER_PROOF_GAPPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Gapped: Self = Self::ORDER_PROOF_GAPPED; + ///Idiomatic alias for [`Self::ORDER_PROOF_UNPROVEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unproven: Self = Self::ORDER_PROOF_UNPROVEN; +} +impl ::core::default::Default for OrderProof { + fn default() -> Self { + Self::ORDER_PROOF_UNSPECIFIED + } +} +impl ::serde::Serialize for OrderProof { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for OrderProof { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = OrderProof; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(OrderProof)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for OrderProof { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for OrderProof { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ORDER_PROOF_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ORDER_PROOF_CONTIGUOUS), + 2i32 => ::core::option::Option::Some(Self::ORDER_PROOF_GAPPED), + 3i32 => ::core::option::Option::Some(Self::ORDER_PROOF_UNPROVEN), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ORDER_PROOF_UNSPECIFIED => "ORDER_PROOF_UNSPECIFIED", + Self::ORDER_PROOF_CONTIGUOUS => "ORDER_PROOF_CONTIGUOUS", + Self::ORDER_PROOF_GAPPED => "ORDER_PROOF_GAPPED", + Self::ORDER_PROOF_UNPROVEN => "ORDER_PROOF_UNPROVEN", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ORDER_PROOF_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ORDER_PROOF_UNSPECIFIED) + } + "ORDER_PROOF_CONTIGUOUS" => { + ::core::option::Option::Some(Self::ORDER_PROOF_CONTIGUOUS) + } + "ORDER_PROOF_GAPPED" => { + ::core::option::Option::Some(Self::ORDER_PROOF_GAPPED) + } + "ORDER_PROOF_UNPROVEN" => { + ::core::option::Option::Some(Self::ORDER_PROOF_UNPROVEN) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ORDER_PROOF_UNSPECIFIED, + Self::ORDER_PROOF_CONTIGUOUS, + Self::ORDER_PROOF_GAPPED, + Self::ORDER_PROOF_UNPROVEN, + ] + } +} +/// Value types shared by the Session maintenance workflows: migration and +/// salvage. +/// +/// Redefined here rather than imported from the write side, following the rule +/// ADR#0035 facet 3 applies to the state, projections, and checkpoints subtrees. +/// A maintenance record outlives the schema it was written under -- that is the +/// entire point of migration provenance -- so it must not be pinned to a +/// write-side type that a migration is free to change. +/// +/// StreamBoundary names an exact cut of one session's own logical stream: how +/// far it extends and what the content at that extent is. +/// +/// Both workflows pin against one, and every indeterminate outcome is ultimately +/// the statement that an observed boundary did not match an expected one. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StreamBoundary { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The 1-indexed SessionOrdinal of the last event in the cut. Fold-derived, + /// never a JetStream sequence, so it survives restore and relocation. + /// + /// Field 2: `ordinal` + #[serde(rename = "ordinal", with = "::buffa::json_helpers::uint64")] + pub ordinal: u64, + /// Field 3: `content_digest` + #[serde(rename = "contentDigest", alias = "content_digest")] + pub content_digest: ::buffa::MessageField< + ContentDigest, + ::buffa::Inline, + >, + /// Which incarnation of the physical stream this cut was taken from: the + /// subject token that isolates one incarnation's subject space from the next, + /// per ADR#0059. Required, because an unset incarnation is not "the same + /// incarnation" and a comparison against one can never fail. + /// + /// A migration's source names the retiring incarnation and its expected target + /// names the new one. Two boundaries carrying different incarnations are not + /// comparable by ordinal, and treating them as comparable is the failure + /// INDETERMINATE_REASON_SOURCE_INCARNATION_CHANGED exists to report. + /// + /// Field 4: `incarnation` + #[serde(rename = "incarnation", with = "::buffa::json_helpers::proto_string")] + pub incarnation: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for StreamBoundary { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StreamBoundary") + .field("session_id", &self.session_id) + .field("ordinal", &self.ordinal) + .field("content_digest", &self.content_digest) + .field("incarnation", &self.incarnation) + .finish() + } +} +impl StreamBoundary { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary"; +} +::buffa::impl_default_instance!(StreamBoundary); +impl ::buffa::MessageName for StreamBoundary { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "StreamBoundary"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary"; +} +impl ::buffa::Message for StreamBoundary { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + if self.content_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.content_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.incarnation) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + if self.content_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.content_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.incarnation, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.content_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.incarnation, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.ordinal = 0u64; + self.content_digest = ::buffa::MessageField::none(); + self.incarnation.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StreamBoundary { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STREAM_BOUNDARY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.StreamBoundary", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ContentDigest commits to the event bytes exactly as the log stores them. +/// +/// Never to a re-serialization. Protobuf encoding is not canonical, so a digest +/// taken over a decode-then-re-encode round trip would not reproduce, and a +/// workflow whose central check is "is this the same content" cannot be built on +/// a comparison that fails against bytes the system itself wrote. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ContentDigest { + /// Field 1: `algorithm` + #[serde(rename = "algorithm", with = "::buffa::json_helpers::proto_string")] + pub algorithm: ::buffa::alloc::string::String, + /// Field 2: `value` + #[serde(rename = "value", with = "::buffa::json_helpers::bytes")] + pub value: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ContentDigest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ContentDigest") + .field("algorithm", &self.algorithm) + .field("value", &self.value) + .finish() + } +} +impl ContentDigest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ContentDigest"; +} +::buffa::impl_default_instance!(ContentDigest); +impl ::buffa::MessageName for ContentDigest { + const PACKAGE: &'static str = "trogonai.session.sessions.maintenance.v1alpha1"; + const NAME: &'static str = "ContentDigest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.maintenance.v1alpha1.ContentDigest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ContentDigest"; +} +impl ::buffa::Message for ContentDigest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.value) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.algorithm, buf); + ::buffa::types::put_shared_bytes_field(2u32, &self.value, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.algorithm, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes(&mut self.value, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.algorithm.clear(); + self.value.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ContentDigest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONTENT_DIGEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.maintenance.v1alpha1.ContentDigest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.__view.rs new file mode 100644 index 0000000000..b80e3400ec --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.__view.rs @@ -0,0 +1,715 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/contract_version.proto + +/// ContractVersion identifies a revision of the Session query contract. +/// +/// Every request declares the highest version its caller understands, and every +/// response reports the version it was actually rendered at. Without both halves +/// a client can only discover an incompatibility by failing to parse a response, +/// which is exactly the outcome this contract exists to prevent. +/// +/// Compatibility rule: +/// +/// - Same `major`: compatible. Anything added within a major is additive, so a +/// ```text +/// caller built against an earlier `minor` can still decode the response. +/// ``` +/// - Different `major`: unsupported. The caller must not attempt to interpret +/// ```text +/// the response, and the server must refuse the request with +/// QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION rather than answer in a +/// shape the caller cannot read. +/// ``` +/// +/// `minor` increments for additive changes only: a new optional field, a new +/// enum value, a new variant in a discriminated union. `major` increments for +/// anything a caller built against the prior version could misread: a removed +/// field, a narrowed type, a changed meaning. +#[derive(Clone, Debug, Default)] +pub struct ContractVersionView<'a> { + /// Incompatible revision. A caller must refuse a response whose major it does + /// not know, rather than interpret the fields it happens to recognize. + /// + /// Field 1: `major` + pub major: u32, + /// Additive revision within a major. + /// + /// Field 2: `minor` + pub minor: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> ContractVersionView<'a> { + /**Whether required field `major` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_major(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `minor` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_minor(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ContractVersionView<'a> { + type Owned = super::super::ContractVersion; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.major = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.minor = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ContractVersion { + major: self.major, + minor: self.minor, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ContractVersionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.major) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.minor) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.major, buf); + ::buffa::types::put_uint32_field(2u32, self.minor, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ContractVersionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "major", + &::buffa::json_helpers::ProtoJson(&self.major), + )?; + } + { + __map + .serialize_entry( + "minor", + &::buffa::json_helpers::ProtoJson(&self.minor), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ContractVersionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ContractVersion"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ContractVersion"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractVersion"; +} +::buffa::impl_default_view_instance!(ContractVersionView); +::buffa::impl_view_reborrow!(ContractVersionView); +/** Self-contained, `'static` owned view of a `ContractVersion` message. + + Wraps [`::buffa::OwnedView`]`<`[`ContractVersionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ContractVersionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ContractVersionOwnedView(::buffa::OwnedView>); +impl ContractVersionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractVersionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractVersionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ContractVersion, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractVersionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ContractVersionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ContractVersionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ContractVersion { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Incompatible revision. A caller must refuse a response whose major it does + /// not know, rather than interpret the fields it happens to recognize. + /// + /// Field 1: `major` + #[must_use] + pub fn major(&self) -> u32 { + self.0.reborrow().major + } + /// Additive revision within a major. + /// + /// Field 2: `minor` + #[must_use] + pub fn minor(&self) -> u32 { + self.0.reborrow().minor + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ContractVersionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ContractVersionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ContractVersionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ContractVersionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ContractVersion { + type View<'a> = ContractVersionView<'a>; + type ViewHandle = ContractVersionOwnedView; +} +impl ::serde::Serialize for ContractVersionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ContractNegotiation is the version block every query response carries. +/// +/// It exists so that "the server understands more than I do" is a fact the +/// caller reads, rather than something it infers from a field it cannot see. +#[derive(Clone, Debug, Default)] +pub struct ContractNegotiationView<'a> { + /// The version this response was rendered at. It is never greater than the + /// caller's declared `accepted_contract`, because the server clamps its output + /// rather than emitting variants the caller cannot decode. + /// + /// Field 1: `rendered` + pub rendered: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// The highest version this server can render. When it exceeds `rendered`, the + /// caller is reading a deliberately narrowed view and an upgrade would show + /// more; the elision counters on the response say whether anything was + /// actually withheld from this particular answer. + /// + /// Field 2: `server_max` + pub server_max: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, +} +impl<'a> ContractNegotiationView<'a> { + /**Whether required field `rendered` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_rendered(&self) -> bool { + self.rendered.is_set() + } + /**Whether required field `server_max` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_server_max(&self) -> bool { + self.server_max.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ContractNegotiationView<'a> { + type Owned = super::super::ContractNegotiation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.rendered.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.rendered = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.server_max.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.server_max = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ContractNegotiation, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ContractNegotiation, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ContractNegotiation { + rendered: match self.rendered.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + server_max: match self.server_max.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ContractNegotiationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.rendered.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.rendered.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.server_max.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.server_max.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.rendered.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.rendered.write_to(__cache, buf); + } + if self.server_max.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.server_max.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ContractNegotiationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.rendered.as_option() { + __map.serialize_entry("rendered", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.server_max.as_option() { + __map.serialize_entry("serverMax", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ContractNegotiationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ContractNegotiation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ContractNegotiation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractNegotiation"; +} +::buffa::impl_default_view_instance!(ContractNegotiationView); +::buffa::impl_view_reborrow!(ContractNegotiationView); +/** Self-contained, `'static` owned view of a `ContractNegotiation` message. + + Wraps [`::buffa::OwnedView`]`<`[`ContractNegotiationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ContractNegotiationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ContractNegotiationOwnedView( + ::buffa::OwnedView>, +); +impl ContractNegotiationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractNegotiationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractNegotiationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ContractNegotiation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContractNegotiationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ContractNegotiationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ContractNegotiationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ContractNegotiation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The version this response was rendered at. It is never greater than the + /// caller's declared `accepted_contract`, because the server clamps its output + /// rather than emitting variants the caller cannot decode. + /// + /// Field 1: `rendered` + #[must_use] + pub fn rendered( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().rendered + } + /// The highest version this server can render. When it exceeds `rendered`, the + /// caller is reading a deliberately narrowed view and an upgrade would show + /// more; the elision counters on the response say whether anything was + /// actually withheld from this particular answer. + /// + /// Field 2: `server_max` + #[must_use] + pub fn server_max( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().server_max + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ContractNegotiationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ContractNegotiationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ContractNegotiationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ContractNegotiationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ContractNegotiation { + type View<'a> = ContractNegotiationView<'a>; + type ViewHandle = ContractNegotiationOwnedView; +} +impl ::serde::Serialize for ContractNegotiationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.rs new file mode 100644 index 0000000000..6b020938a9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.contract_version.rs @@ -0,0 +1,319 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/contract_version.proto + +/// ContractVersion identifies a revision of the Session query contract. +/// +/// Every request declares the highest version its caller understands, and every +/// response reports the version it was actually rendered at. Without both halves +/// a client can only discover an incompatibility by failing to parse a response, +/// which is exactly the outcome this contract exists to prevent. +/// +/// Compatibility rule: +/// +/// - Same `major`: compatible. Anything added within a major is additive, so a +/// ```text +/// caller built against an earlier `minor` can still decode the response. +/// ``` +/// - Different `major`: unsupported. The caller must not attempt to interpret +/// ```text +/// the response, and the server must refuse the request with +/// QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION rather than answer in a +/// shape the caller cannot read. +/// ``` +/// +/// `minor` increments for additive changes only: a new optional field, a new +/// enum value, a new variant in a discriminated union. `major` increments for +/// anything a caller built against the prior version could misread: a removed +/// field, a narrowed type, a changed meaning. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ContractVersion { + /// Incompatible revision. A caller must refuse a response whose major it does + /// not know, rather than interpret the fields it happens to recognize. + /// + /// Field 1: `major` + #[serde(rename = "major", with = "::buffa::json_helpers::uint32")] + pub major: u32, + /// Additive revision within a major. + /// + /// Field 2: `minor` + #[serde(rename = "minor", with = "::buffa::json_helpers::uint32")] + pub minor: u32, +} +impl ::core::fmt::Debug for ContractVersion { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ContractVersion") + .field("major", &self.major) + .field("minor", &self.minor) + .finish() + } +} +impl ContractVersion { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractVersion"; +} +::buffa::impl_default_instance!(ContractVersion); +impl ::buffa::MessageName for ContractVersion { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ContractVersion"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ContractVersion"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractVersion"; +} +impl ::buffa::Message for ContractVersion { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.major) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.minor) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.major, buf); + ::buffa::types::put_uint32_field(2u32, self.minor, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.major = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.minor = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.major = 0u32; + self.minor = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ContractVersion { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONTRACT_VERSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractVersion", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ContractNegotiation is the version block every query response carries. +/// +/// It exists so that "the server understands more than I do" is a fact the +/// caller reads, rather than something it infers from a field it cannot see. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ContractNegotiation { + /// The version this response was rendered at. It is never greater than the + /// caller's declared `accepted_contract`, because the server clamps its output + /// rather than emitting variants the caller cannot decode. + /// + /// Field 1: `rendered` + #[serde(rename = "rendered")] + pub rendered: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// The highest version this server can render. When it exceeds `rendered`, the + /// caller is reading a deliberately narrowed view and an upgrade would show + /// more; the elision counters on the response say whether anything was + /// actually withheld from this particular answer. + /// + /// Field 2: `server_max` + #[serde(rename = "serverMax", alias = "server_max")] + pub server_max: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ContractNegotiation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ContractNegotiation") + .field("rendered", &self.rendered) + .field("server_max", &self.server_max) + .finish() + } +} +impl ContractNegotiation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractNegotiation"; +} +::buffa::impl_default_instance!(ContractNegotiation); +impl ::buffa::MessageName for ContractNegotiation { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ContractNegotiation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ContractNegotiation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractNegotiation"; +} +impl ::buffa::Message for ContractNegotiation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.rendered.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.rendered.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.server_max.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.server_max.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.rendered.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.rendered.write_to(__cache, buf); + } + if self.server_max.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.server_max.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.rendered.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.server_max.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.rendered = ::buffa::MessageField::none(); + self.server_max = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ContractNegotiation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONTRACT_NEGOTIATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ContractNegotiation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.__view.rs new file mode 100644 index 0000000000..fffdb94ebb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.__view.rs @@ -0,0 +1,852 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/get_session.proto + +/// GetSessionRequest reads one session's detail view. +/// +/// The caller declares the contract version it understands. This is what turns +/// an incompatibility into a typed refusal instead of a parse failure: the +/// server can see, before rendering anything, whether the caller can read the +/// answer. +#[derive(Clone, Debug, Default)] +pub struct GetSessionRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The highest contract version this caller understands. The server renders at + /// no higher than this, and refuses outright when the major does not match. + /// + /// Field 2: `accepted_contract` + pub accepted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 3: `consistency` + pub consistency: ::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetSessionRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `accepted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_accepted_contract(&self) -> bool { + self.accepted_contract.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for GetSessionRequestView<'a> { + type Owned = super::super::GetSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.accepted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.accepted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.consistency.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.consistency = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetSessionRequest { + session_id: self.session_id.to_string(), + accepted_contract: match self.accepted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + consistency: match self.consistency.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReadConsistency, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.accepted_contract.as_option() + { + __map.serialize_entry("acceptedContract", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.consistency.as_option() { + __map.serialize_entry("consistency", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionRequest"; +} +::buffa::impl_default_view_instance!(GetSessionRequestView); +::buffa::impl_view_reborrow!(GetSessionRequestView); +/** Self-contained, `'static` owned view of a `GetSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl GetSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The highest contract version this caller understands. The server renders at + /// no higher than this, and refuses outright when the major does not match. + /// + /// Field 2: `accepted_contract` + #[must_use] + pub fn accepted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().accepted_contract + } + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 3: `consistency` + #[must_use] + pub fn consistency( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'_>, + > { + &self.0.reborrow().consistency + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetSessionRequest { + type View<'a> = GetSessionRequestView<'a>; + type ViewHandle = GetSessionRequestOwnedView; +} +impl ::serde::Serialize for GetSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// GetSessionResponse is a session's detail view. +/// +/// A failure is not a variant here. It arrives as a QueryError on the +/// transport's error channel, so a caller can never read a zero-valued success +/// shape as an empty answer. +#[derive(Clone, Debug, Default)] +pub struct GetSessionResponseView<'a> { + /// Field 1: `contract` + pub contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'a>, + >, + /// Field 2: `session` + pub session: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionViewView<'a>, + >, + /// How current the read model was when it answered. Always present, including + /// on an eventual read, so currency is something the server stated rather than + /// something the caller assumed. + /// + /// Field 3: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, +} +impl<'a> GetSessionResponseView<'a> { + /**Whether required field `contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract(&self) -> bool { + self.contract.is_set() + } + /**Whether required field `session` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session(&self) -> bool { + self.session.is_set() + } + /**Whether required field `freshness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_freshness(&self) -> bool { + self.freshness.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for GetSessionResponseView<'a> { + type Owned = super::super::GetSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.session.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.session = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetSessionResponse { + contract: match self.contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractNegotiation, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + session: match self.session.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.session.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + if self.session.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.contract.as_option() { + __map.serialize_entry("contract", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.session.as_option() { + __map.serialize_entry("session", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionResponse"; +} +::buffa::impl_default_view_instance!(GetSessionResponseView); +::buffa::impl_view_reborrow!(GetSessionResponseView); +/** Self-contained, `'static` owned view of a `GetSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl GetSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `contract` + #[must_use] + pub fn contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'_>, + > { + &self.0.reborrow().contract + } + /// Field 2: `session` + #[must_use] + pub fn session( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().session + } + /// How current the read model was when it answered. Always present, including + /// on an eventual read, so currency is something the server stated rather than + /// something the caller assumed. + /// + /// Field 3: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetSessionResponse { + type View<'a> = GetSessionResponseView<'a>; + type ViewHandle = GetSessionResponseOwnedView; +} +impl ::serde::Serialize for GetSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.rs new file mode 100644 index 0000000000..ebb372f7ab --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session.rs @@ -0,0 +1,392 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/get_session.proto + +/// GetSessionRequest reads one session's detail view. +/// +/// The caller declares the contract version it understands. This is what turns +/// an incompatibility into a typed refusal instead of a parse failure: the +/// server can see, before rendering anything, whether the caller can read the +/// answer. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSessionRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The highest contract version this caller understands. The server renders at + /// no higher than this, and refuses outright when the major does not match. + /// + /// Field 2: `accepted_contract` + #[serde(rename = "acceptedContract", alias = "accepted_contract")] + pub accepted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 3: `consistency` + #[serde( + rename = "consistency", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub consistency: ::buffa::MessageField< + ReadConsistency, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSessionRequest") + .field("session_id", &self.session_id) + .field("accepted_contract", &self.accepted_contract) + .field("consistency", &self.consistency) + .finish() + } +} +impl GetSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionRequest"; +} +::buffa::impl_default_instance!(GetSessionRequest); +impl ::buffa::MessageName for GetSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionRequest"; +} +impl ::buffa::Message for GetSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.accepted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.consistency.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.accepted_contract = ::buffa::MessageField::none(); + self.consistency = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// GetSessionResponse is a session's detail view. +/// +/// A failure is not a variant here. It arrives as a QueryError on the +/// transport's error channel, so a caller can never read a zero-valued success +/// shape as an empty answer. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSessionResponse { + /// Field 1: `contract` + #[serde(rename = "contract")] + pub contract: ::buffa::MessageField< + ContractNegotiation, + ::buffa::Inline, + >, + /// Field 2: `session` + #[serde(rename = "session")] + pub session: ::buffa::MessageField>, + /// How current the read model was when it answered. Always present, including + /// on an eventual read, so currency is something the server stated rather than + /// something the caller assumed. + /// + /// Field 3: `freshness` + #[serde(rename = "freshness")] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSessionResponse") + .field("contract", &self.contract) + .field("session", &self.session) + .field("freshness", &self.freshness) + .finish() + } +} +impl GetSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionResponse"; +} +::buffa::impl_default_instance!(GetSessionResponse); +impl ::buffa::MessageName for GetSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionResponse"; +} +impl ::buffa::Message for GetSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.session.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + if self.session.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.session.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.contract = ::buffa::MessageField::none(); + self.session = ::buffa::MessageField::none(); + self.freshness = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.__view.rs new file mode 100644 index 0000000000..b1447ed7ff --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.__view.rs @@ -0,0 +1,1131 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/get_session_history.proto + +/// GetSessionHistoryRequest reads one page of a session's history. +/// +/// History is a separate query from GetSession because it is unbounded. A detail +/// read that inlined it would have no bound on its response size, and a client +/// would have no way to ask for less. +#[derive(Clone, Debug, Default)] +pub struct GetSessionHistoryRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `accepted_contract` + pub accepted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Field 3: `direction` + pub direction: ::buffa::EnumValue, + /// Field 4: `page_size` + pub page_size: u32, + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. `direction` is fixed when the scan opens, so a + /// continuation that disagrees with the cursor is refused rather than + /// reversed. + /// + /// Field 5: `page_token` + pub page_token: ::core::option::Option<&'a [u8]>, + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, whose contents are fixed by the anchor. A continuation + /// asking for more than the scan was opened with is + /// QUERY_ERROR_CODE_INVALID_ARGUMENT. + /// + /// This is the field that answers "does this transcript include the redaction + /// I just applied". An eventual read cannot say, and the anchor alone cannot + /// either: it says which ordinal the scan covers, not whether the projection + /// had applied the event at that ordinal when the scan opened. + /// + /// Field 6: `consistency` + pub consistency: ::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetSessionHistoryRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `accepted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_accepted_contract(&self) -> bool { + self.accepted_contract.is_set() + } + /**Whether required field `direction` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_direction(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `page_size` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_page_size(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for GetSessionHistoryRequestView<'a> { + type Owned = super::super::GetSessionHistoryRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.accepted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.accepted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.direction = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.page_size = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.consistency.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.consistency = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetSessionHistoryRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetSessionHistoryRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetSessionHistoryRequest { + session_id: self.session_id.to_string(), + accepted_contract: match self.accepted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + direction: self.direction, + page_size: self.page_size, + page_token: self.page_token.map(|b| (b).to_vec()), + consistency: match self.consistency.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReadConsistency, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetSessionHistoryRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.direction.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.direction.to_i32(), buf); + ::buffa::types::put_uint32_field(4u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(5u32, v, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetSessionHistoryRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.accepted_contract.as_option() + { + __map.serialize_entry("acceptedContract", __v)?; + } + } + { + __map.serialize_entry("direction", &self.direction)?; + } + { + __map + .serialize_entry( + "pageSize", + &::buffa::json_helpers::ProtoJson(&self.page_size), + )?; + } + if let ::core::option::Option::Some(__v) = self.page_token { + __map.serialize_entry("pageToken", &::buffa::json_helpers::BytesJson(__v))?; + } + { + if let ::core::option::Option::Some(__v) = self.consistency.as_option() { + __map.serialize_entry("consistency", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetSessionHistoryRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionHistoryRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest"; +} +::buffa::impl_default_view_instance!(GetSessionHistoryRequestView); +::buffa::impl_view_reborrow!(GetSessionHistoryRequestView); +/** Self-contained, `'static` owned view of a `GetSessionHistoryRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetSessionHistoryRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetSessionHistoryRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetSessionHistoryRequestOwnedView( + ::buffa::OwnedView>, +); +impl GetSessionHistoryRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetSessionHistoryRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetSessionHistoryRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetSessionHistoryRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetSessionHistoryRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `accepted_contract` + #[must_use] + pub fn accepted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().accepted_contract + } + /// Field 3: `direction` + #[must_use] + pub fn direction(&self) -> ::buffa::EnumValue { + self.0.reborrow().direction + } + /// Field 4: `page_size` + #[must_use] + pub fn page_size(&self) -> u32 { + self.0.reborrow().page_size + } + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. `direction` is fixed when the scan opens, so a + /// continuation that disagrees with the cursor is refused rather than + /// reversed. + /// + /// Field 5: `page_token` + #[must_use] + pub fn page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().page_token + } + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, whose contents are fixed by the anchor. A continuation + /// asking for more than the scan was opened with is + /// QUERY_ERROR_CODE_INVALID_ARGUMENT. + /// + /// This is the field that answers "does this transcript include the redaction + /// I just applied". An eventual read cannot say, and the anchor alone cannot + /// either: it says which ordinal the scan covers, not whether the projection + /// had applied the event at that ordinal when the scan opened. + /// + /// Field 6: `consistency` + #[must_use] + pub fn consistency( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'_>, + > { + &self.0.reborrow().consistency + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetSessionHistoryRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetSessionHistoryRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetSessionHistoryRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetSessionHistoryRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetSessionHistoryRequest { + type View<'a> = GetSessionHistoryRequestView<'a>; + type ViewHandle = GetSessionHistoryRequestOwnedView; +} +impl ::serde::Serialize for GetSessionHistoryRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// GetSessionHistoryResponse is one page of history items. +/// +/// The elision counters are the honest part of this message. A caller that reads +/// only `items` cannot tell a complete page from one that quietly dropped half +/// its content, and "the response parsed" is not evidence that it is complete. +#[derive(Clone, Debug, Default)] +pub struct GetSessionHistoryResponseView<'a> { + /// Field 1: `contract` + pub contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'a>, + >, + /// Field 2: `items` + pub items: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::HistoryItemView<'a>, + >, + /// Unset when the scan is exhausted. Presence, not an empty `items` list, is + /// the end signal. + /// + /// Field 3: `next_page_token` + pub next_page_token: ::core::option::Option<&'a [u8]>, + /// Items on this page rendered as HISTORY_ITEM_KIND_ELIDED because they need a + /// variant newer than the caller's contract minor. Non-zero means upgrading + /// the caller would show more. + /// + /// Field 4: `contract_clamped_count` + pub contract_clamped_count: u32, + /// Items on this page whose content was withheld by redaction or + /// authorization. Distinct from the clamped count: upgrading the caller will + /// not reveal these, and a client should not prompt for an upgrade. + /// + /// Field 5: `withheld_count` + pub withheld_count: u32, + /// The effective history boundary this page was rendered against, after + /// rewind masking, as a SessionOrdinal. It is the scan's anchor and is equal + /// on every page of one scan. + /// + /// Turns appended after the scan opened are above this boundary and are not + /// in it. That is the property that keeps paging stable while a session is + /// still being written to, and it means an in-progress scan is not how a + /// caller learns about new turns. Should the effective boundary itself move, + /// by rewind or redaction, the continuation fails with STALE_CURSOR rather + /// than quietly reporting a different value here. + /// + /// Field 6: `effective_through` + pub effective_through: u64, + /// How current the read model was when the scan opened. Equal on every page. + /// + /// Field 7: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetSessionHistoryResponseView<'a> { + /**Whether required field `contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract(&self) -> bool { + self.contract.is_set() + } + /**Whether required field `contract_clamped_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract_clamped_count(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `withheld_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_withheld_count(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `effective_through` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_effective_through(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `freshness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_freshness(&self) -> bool { + self.freshness.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for GetSessionHistoryResponseView<'a> { + type Owned = super::super::GetSessionHistoryResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.next_page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.contract_clamped_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.withheld_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.effective_through = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::HistoryItemView, + >(), + )?; + view.items + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetSessionHistoryResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetSessionHistoryResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetSessionHistoryResponse { + contract: match self.contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractNegotiation, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + items: self + .items + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + next_page_token: self.next_page_token.map(|b| (b).to_vec()), + contract_clamped_count: self.contract_clamped_count, + withheld_count: self.withheld_count, + effective_through: self.effective_through, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetSessionHistoryResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.items { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.contract_clamped_count) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.withheld_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.effective_through) as u64; + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + for v in &self.items { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + ::buffa::types::put_uint32_field(4u32, self.contract_clamped_count, buf); + ::buffa::types::put_uint32_field(5u32, self.withheld_count, buf); + ::buffa::types::put_uint64_field(6u32, self.effective_through, buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetSessionHistoryResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.contract.as_option() { + __map.serialize_entry("contract", __v)?; + } + } + if !self.items.is_empty() { + __map.serialize_entry("items", &*self.items)?; + } + if let ::core::option::Option::Some(__v) = self.next_page_token { + __map + .serialize_entry( + "nextPageToken", + &::buffa::json_helpers::BytesJson(__v), + )?; + } + { + __map + .serialize_entry( + "contractClampedCount", + &::buffa::json_helpers::ProtoJson(&self.contract_clamped_count), + )?; + } + { + __map + .serialize_entry( + "withheldCount", + &::buffa::json_helpers::ProtoJson(&self.withheld_count), + )?; + } + { + __map + .serialize_entry( + "effectiveThrough", + &::buffa::json_helpers::ProtoJson(&self.effective_through), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetSessionHistoryResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionHistoryResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse"; +} +::buffa::impl_default_view_instance!(GetSessionHistoryResponseView); +::buffa::impl_view_reborrow!(GetSessionHistoryResponseView); +/** Self-contained, `'static` owned view of a `GetSessionHistoryResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetSessionHistoryResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetSessionHistoryResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetSessionHistoryResponseOwnedView( + ::buffa::OwnedView>, +); +impl GetSessionHistoryResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetSessionHistoryResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetSessionHistoryResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetSessionHistoryResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetSessionHistoryResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetSessionHistoryResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `contract` + #[must_use] + pub fn contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'_>, + > { + &self.0.reborrow().contract + } + /// Field 2: `items` + #[must_use] + pub fn items( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::HistoryItemView<'_>> { + &self.0.reborrow().items + } + /// Unset when the scan is exhausted. Presence, not an empty `items` list, is + /// the end signal. + /// + /// Field 3: `next_page_token` + #[must_use] + pub fn next_page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().next_page_token + } + /// Items on this page rendered as HISTORY_ITEM_KIND_ELIDED because they need a + /// variant newer than the caller's contract minor. Non-zero means upgrading + /// the caller would show more. + /// + /// Field 4: `contract_clamped_count` + #[must_use] + pub fn contract_clamped_count(&self) -> u32 { + self.0.reborrow().contract_clamped_count + } + /// Items on this page whose content was withheld by redaction or + /// authorization. Distinct from the clamped count: upgrading the caller will + /// not reveal these, and a client should not prompt for an upgrade. + /// + /// Field 5: `withheld_count` + #[must_use] + pub fn withheld_count(&self) -> u32 { + self.0.reborrow().withheld_count + } + /// The effective history boundary this page was rendered against, after + /// rewind masking, as a SessionOrdinal. It is the scan's anchor and is equal + /// on every page of one scan. + /// + /// Turns appended after the scan opened are above this boundary and are not + /// in it. That is the property that keeps paging stable while a session is + /// still being written to, and it means an in-progress scan is not how a + /// caller learns about new turns. Should the effective boundary itself move, + /// by rewind or redaction, the continuation fails with STALE_CURSOR rather + /// than quietly reporting a different value here. + /// + /// Field 6: `effective_through` + #[must_use] + pub fn effective_through(&self) -> u64 { + self.0.reborrow().effective_through + } + /// How current the read model was when the scan opened. Equal on every page. + /// + /// Field 7: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetSessionHistoryResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetSessionHistoryResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetSessionHistoryResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetSessionHistoryResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetSessionHistoryResponse { + type View<'a> = GetSessionHistoryResponseView<'a>; + type ViewHandle = GetSessionHistoryResponseOwnedView; +} +impl ::serde::Serialize for GetSessionHistoryResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.rs new file mode 100644 index 0000000000..a04ded2d53 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.get_session_history.rs @@ -0,0 +1,752 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/get_session_history.proto + +/// HistoryDirection is which end of history a fresh scan starts from. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum HistoryDirection { + HISTORY_DIRECTION_UNSPECIFIED = 0i32, + /// Oldest first. + HISTORY_DIRECTION_FORWARD = 1i32, + /// Newest first, the usual transcript-scrollback order. + HISTORY_DIRECTION_REVERSE = 2i32, +} +impl HistoryDirection { + ///Idiomatic alias for [`Self::HISTORY_DIRECTION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::HISTORY_DIRECTION_UNSPECIFIED; + ///Idiomatic alias for [`Self::HISTORY_DIRECTION_FORWARD`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Forward: Self = Self::HISTORY_DIRECTION_FORWARD; + ///Idiomatic alias for [`Self::HISTORY_DIRECTION_REVERSE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Reverse: Self = Self::HISTORY_DIRECTION_REVERSE; +} +impl ::core::default::Default for HistoryDirection { + fn default() -> Self { + Self::HISTORY_DIRECTION_UNSPECIFIED + } +} +impl ::serde::Serialize for HistoryDirection { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for HistoryDirection { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = HistoryDirection; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(HistoryDirection) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for HistoryDirection { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for HistoryDirection { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::HISTORY_DIRECTION_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::HISTORY_DIRECTION_FORWARD), + 2i32 => ::core::option::Option::Some(Self::HISTORY_DIRECTION_REVERSE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::HISTORY_DIRECTION_UNSPECIFIED => "HISTORY_DIRECTION_UNSPECIFIED", + Self::HISTORY_DIRECTION_FORWARD => "HISTORY_DIRECTION_FORWARD", + Self::HISTORY_DIRECTION_REVERSE => "HISTORY_DIRECTION_REVERSE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "HISTORY_DIRECTION_UNSPECIFIED" => { + ::core::option::Option::Some(Self::HISTORY_DIRECTION_UNSPECIFIED) + } + "HISTORY_DIRECTION_FORWARD" => { + ::core::option::Option::Some(Self::HISTORY_DIRECTION_FORWARD) + } + "HISTORY_DIRECTION_REVERSE" => { + ::core::option::Option::Some(Self::HISTORY_DIRECTION_REVERSE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::HISTORY_DIRECTION_UNSPECIFIED, + Self::HISTORY_DIRECTION_FORWARD, + Self::HISTORY_DIRECTION_REVERSE, + ] + } +} +/// GetSessionHistoryRequest reads one page of a session's history. +/// +/// History is a separate query from GetSession because it is unbounded. A detail +/// read that inlined it would have no bound on its response size, and a client +/// would have no way to ask for less. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSessionHistoryRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `accepted_contract` + #[serde(rename = "acceptedContract", alias = "accepted_contract")] + pub accepted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Field 3: `direction` + #[serde(rename = "direction", with = "::buffa::json_helpers::proto_enum")] + pub direction: ::buffa::EnumValue, + /// Field 4: `page_size` + #[serde( + rename = "pageSize", + alias = "page_size", + with = "::buffa::json_helpers::uint32" + )] + pub page_size: u32, + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. `direction` is fixed when the scan opens, so a + /// continuation that disagrees with the cursor is refused rather than + /// reversed. + /// + /// Field 5: `page_token` + #[serde( + rename = "pageToken", + alias = "page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, whose contents are fixed by the anchor. A continuation + /// asking for more than the scan was opened with is + /// QUERY_ERROR_CODE_INVALID_ARGUMENT. + /// + /// This is the field that answers "does this transcript include the redaction + /// I just applied". An eventual read cannot say, and the anchor alone cannot + /// either: it says which ordinal the scan covers, not whether the projection + /// had applied the event at that ordinal when the scan opened. + /// + /// Field 6: `consistency` + #[serde( + rename = "consistency", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub consistency: ::buffa::MessageField< + ReadConsistency, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetSessionHistoryRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSessionHistoryRequest") + .field("session_id", &self.session_id) + .field("accepted_contract", &self.accepted_contract) + .field("direction", &self.direction) + .field("page_size", &self.page_size) + .field("page_token", &self.page_token) + .field("consistency", &self.consistency) + .finish() + } +} +impl GetSessionHistoryRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest"; +} +impl GetSessionHistoryRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(GetSessionHistoryRequest); +impl ::buffa::MessageName for GetSessionHistoryRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionHistoryRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest"; +} +impl ::buffa::Message for GetSessionHistoryRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.direction.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.direction.to_i32(), buf); + ::buffa::types::put_uint32_field(4u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(5u32, v, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.accepted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.direction = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.page_size = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self.page_token.get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.consistency.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.accepted_contract = ::buffa::MessageField::none(); + self.direction = ::buffa::EnumValue::from(0); + self.page_size = 0u32; + self.page_token = ::core::option::Option::None; + self.consistency = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSessionHistoryRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SESSION_HISTORY_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// GetSessionHistoryResponse is one page of history items. +/// +/// The elision counters are the honest part of this message. A caller that reads +/// only `items` cannot tell a complete page from one that quietly dropped half +/// its content, and "the response parsed" is not evidence that it is complete. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSessionHistoryResponse { + /// Field 1: `contract` + #[serde(rename = "contract")] + pub contract: ::buffa::MessageField< + ContractNegotiation, + ::buffa::Inline, + >, + /// Field 2: `items` + #[serde( + rename = "items", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub items: ::buffa::alloc::vec::Vec, + /// Unset when the scan is exhausted. Presence, not an empty `items` list, is + /// the end signal. + /// + /// Field 3: `next_page_token` + #[serde( + rename = "nextPageToken", + alias = "next_page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub next_page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Items on this page rendered as HISTORY_ITEM_KIND_ELIDED because they need a + /// variant newer than the caller's contract minor. Non-zero means upgrading + /// the caller would show more. + /// + /// Field 4: `contract_clamped_count` + #[serde( + rename = "contractClampedCount", + alias = "contract_clamped_count", + with = "::buffa::json_helpers::uint32" + )] + pub contract_clamped_count: u32, + /// Items on this page whose content was withheld by redaction or + /// authorization. Distinct from the clamped count: upgrading the caller will + /// not reveal these, and a client should not prompt for an upgrade. + /// + /// Field 5: `withheld_count` + #[serde( + rename = "withheldCount", + alias = "withheld_count", + with = "::buffa::json_helpers::uint32" + )] + pub withheld_count: u32, + /// The effective history boundary this page was rendered against, after + /// rewind masking, as a SessionOrdinal. It is the scan's anchor and is equal + /// on every page of one scan. + /// + /// Turns appended after the scan opened are above this boundary and are not + /// in it. That is the property that keeps paging stable while a session is + /// still being written to, and it means an in-progress scan is not how a + /// caller learns about new turns. Should the effective boundary itself move, + /// by rewind or redaction, the continuation fails with STALE_CURSOR rather + /// than quietly reporting a different value here. + /// + /// Field 6: `effective_through` + #[serde( + rename = "effectiveThrough", + alias = "effective_through", + with = "::buffa::json_helpers::uint64" + )] + pub effective_through: u64, + /// How current the read model was when the scan opened. Equal on every page. + /// + /// Field 7: `freshness` + #[serde(rename = "freshness")] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetSessionHistoryResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSessionHistoryResponse") + .field("contract", &self.contract) + .field("items", &self.items) + .field("next_page_token", &self.next_page_token) + .field("contract_clamped_count", &self.contract_clamped_count) + .field("withheld_count", &self.withheld_count) + .field("effective_through", &self.effective_through) + .field("freshness", &self.freshness) + .finish() + } +} +impl GetSessionHistoryResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse"; +} +impl GetSessionHistoryResponse { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::next_page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_next_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.next_page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(GetSessionHistoryResponse); +impl ::buffa::MessageName for GetSessionHistoryResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetSessionHistoryResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse"; +} +impl ::buffa::Message for GetSessionHistoryResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.items { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.contract_clamped_count) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.withheld_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.effective_through) as u64; + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + for v in &self.items { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + ::buffa::types::put_uint32_field(4u32, self.contract_clamped_count, buf); + ::buffa::types::put_uint32_field(5u32, self.withheld_count, buf); + ::buffa::types::put_uint64_field(6u32, self.effective_through, buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.items.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self + .next_page_token + .get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.contract_clamped_count = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.withheld_count = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.effective_through = ::buffa::types::decode_uint64(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.contract = ::buffa::MessageField::none(); + self.items.clear(); + self.next_page_token = ::core::option::Option::None; + self.contract_clamped_count = 0u32; + self.withheld_count = 0u32; + self.effective_through = 0u64; + self.freshness = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSessionHistoryResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SESSION_HISTORY_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetSessionHistoryResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__oneof.rs new file mode 100644 index 0000000000..9db02a85a0 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__oneof.rs @@ -0,0 +1,124 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/history_item.proto + +pub mod history_item { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Item { + UserMessage(::buffa::alloc::boxed::Box), + AssistantMessage( + ::buffa::alloc::boxed::Box, + ), + ToolCall(::buffa::alloc::boxed::Box), + FileChange(::buffa::alloc::boxed::Box), + SystemNotice(::buffa::alloc::boxed::Box), + Compaction(::buffa::alloc::boxed::Box), + Elided(::buffa::alloc::boxed::Box), + } + impl ::buffa::Oneof for Item {} + impl From for Item { + fn from(v: super::super::super::UserMessageItem) -> Self { + Self::UserMessage(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::UserMessageItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::AssistantMessageItem) -> Self { + Self::AssistantMessage(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::AssistantMessageItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::ToolCallItem) -> Self { + Self::ToolCall(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::ToolCallItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::FileChangeItem) -> Self { + Self::FileChange(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::FileChangeItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::SystemNoticeItem) -> Self { + Self::SystemNotice(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::SystemNoticeItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::CompactionItem) -> Self { + Self::Compaction(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::CompactionItem) -> Self { + Self::Some(Item::from(v)) + } + } + impl From for Item { + fn from(v: super::super::super::HistoryItemElided) -> Self { + Self::Elided(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::HistoryItemElided) -> Self { + Self::Some(Item::from(v)) + } + } + impl serde::Serialize for Item { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::UserMessage(v) => { + map.serialize_entry("userMessage", v)?; + } + Self::AssistantMessage(v) => { + map.serialize_entry("assistantMessage", v)?; + } + Self::ToolCall(v) => { + map.serialize_entry("toolCall", v)?; + } + Self::FileChange(v) => { + map.serialize_entry("fileChange", v)?; + } + Self::SystemNotice(v) => { + map.serialize_entry("systemNotice", v)?; + } + Self::Compaction(v) => { + map.serialize_entry("compaction", v)?; + } + Self::Elided(v) => { + map.serialize_entry("elided", v)?; + } + } + map.end() + } + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view.rs new file mode 100644 index 0000000000..76b5f60667 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view.rs @@ -0,0 +1,3172 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/history_item.proto + +/// HistoryItem is one entry in a session's reader-visible history. +/// +/// The discriminated-union hazard this shape is built around: a caller decoding +/// a `oneof` arm added after its contract minor sees an unset `oneof` and cannot +/// distinguish "a variant I do not know" from "a variant that was not set". +/// Silently rendering nothing for a real event is a correctness failure, not a +/// cosmetic one. +/// +/// Two mechanisms close that gap: +/// +/// 1. `kind` is a plain enum outside the `oneof`. Proto enums are open, so an +/// ```text +/// unrecognized kind decodes as its raw number rather than vanishing, and a +/// caller can always tell that something is here it does not understand. +/// ``` +/// 2. The server clamps to the caller's declared contract minor and emits +/// ```text +/// HISTORY_ITEM_KIND_ELIDED with an `elided` payload rather than a variant +/// the caller cannot decode. Elision is affirmative: the caller reads that +/// an item was withheld instead of inferring it from an empty field. +/// ``` +#[derive(Clone, Debug, Default)] +pub struct HistoryItemView<'a> { + /// Stable within a session, opaque, and safe to use as a rendering key. It + /// remains stable across an elision, so a client that upgrades sees the same + /// item resolve to a real variant. + /// + /// Field 1: `item_id` + pub item_id: &'a str, + /// The session's own 1-indexed position for this item. + /// + /// Field 2: `ordinal` + pub ordinal: u64, + /// Set even when the matching `item` arm is absent, so an unknown or withheld + /// item is still identifiable. + /// + /// Field 3: `kind` + pub kind: ::buffa::EnumValue, + pub item: ::core::option::Option< + super::super::__buffa::view::oneof::history_item::Item<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> HistoryItemView<'a> { + /**Whether required field `item_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_item_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for HistoryItemView<'a> { + type Owned = super::super::HistoryItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.item_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::ToolCall( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::ToolCall( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::FileChange( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::FileChange( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::Compaction( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::Compaction( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::history_item::Item::Elided( + ref mut existing, + ), + ) = view.item + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.item = Some( + super::super::__buffa::view::oneof::history_item::Item::Elided( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::HistoryItem { + item_id: self.item_id.to_string(), + ordinal: self.ordinal, + kind: self.kind, + item: match self.item.as_ref() { + ::core::option::Option::Some(v) => { + ::core::option::Option::Some( + match v { + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::UserMessage( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::AssistantMessage( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::ToolCall( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::ToolCall( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::FileChange( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::FileChange( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::SystemNotice( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::Compaction( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::Compaction( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::history_item::Item::Elided( + v, + ) => { + super::super::__buffa::oneof::history_item::Item::Elided( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + }, + ) + } + ::core::option::Option::None => ::core::option::Option::None, + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for HistoryItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.item_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let ::core::option::Option::Some(ref v) = self.item { + match v { + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::ToolCall(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::FileChange( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::Compaction( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::history_item::Item::Elided(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.item_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + ::buffa::types::put_int32_field(3u32, self.kind.to_i32(), buf); + if let ::core::option::Option::Some(ref v) = self.item { + match v { + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::ToolCall(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::FileChange( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::Compaction( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::history_item::Item::Elided(x) => { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for HistoryItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("itemId", self.item_id)?; + } + { + __map + .serialize_entry( + "ordinal", + &::buffa::json_helpers::ProtoJson(&self.ordinal), + )?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(ref __ov) = self.item { + match __ov { + super::super::__buffa::view::oneof::history_item::Item::UserMessage( + v, + ) => { + __map.serialize_entry("userMessage", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::AssistantMessage( + v, + ) => { + __map.serialize_entry("assistantMessage", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::ToolCall(v) => { + __map.serialize_entry("toolCall", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::FileChange( + v, + ) => { + __map.serialize_entry("fileChange", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::SystemNotice( + v, + ) => { + __map.serialize_entry("systemNotice", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::Compaction( + v, + ) => { + __map.serialize_entry("compaction", v)?; + } + super::super::__buffa::view::oneof::history_item::Item::Elided(v) => { + __map.serialize_entry("elided", v)?; + } + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for HistoryItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItem"; +} +::buffa::impl_default_view_instance!(HistoryItemView); +::buffa::impl_view_reborrow!(HistoryItemView); +/** Self-contained, `'static` owned view of a `HistoryItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`HistoryItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`HistoryItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct HistoryItemOwnedView(::buffa::OwnedView>); +impl HistoryItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::HistoryItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`HistoryItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &HistoryItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::HistoryItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Stable within a session, opaque, and safe to use as a rendering key. It + /// remains stable across an elision, so a client that upgrades sees the same + /// item resolve to a real variant. + /// + /// Field 1: `item_id` + #[must_use] + pub fn item_id(&self) -> &'_ str { + self.0.reborrow().item_id + } + /// The session's own 1-indexed position for this item. + /// + /// Field 2: `ordinal` + #[must_use] + pub fn ordinal(&self) -> u64 { + self.0.reborrow().ordinal + } + /// Set even when the matching `item` arm is absent, so an unknown or withheld + /// item is still identifiable. + /// + /// Field 3: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Oneof `item`. + #[must_use] + pub fn item( + &self, + ) -> ::core::option::Option< + &super::super::__buffa::view::oneof::history_item::Item<'_>, + > { + self.0.reborrow().item.as_ref() + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for HistoryItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + HistoryItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: HistoryItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for HistoryItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::HistoryItem { + type View<'a> = HistoryItemView<'a>; + type ViewHandle = HistoryItemOwnedView; +} +impl ::serde::Serialize for HistoryItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// HistoryItemElided is an item the server chose not to render, stated +/// affirmatively so a caller never mistakes a withheld item for a missing one. +#[derive(Clone, Debug, Default)] +pub struct HistoryItemElidedView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> HistoryItemElidedView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for HistoryItemElidedView<'a> { + type Owned = super::super::HistoryItemElided; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::HistoryItemElided { + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for HistoryItemElidedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for HistoryItemElidedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for HistoryItemElidedView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryItemElided"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryItemElided"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItemElided"; +} +::buffa::impl_default_view_instance!(HistoryItemElidedView); +::buffa::impl_view_reborrow!(HistoryItemElidedView); +/** Self-contained, `'static` owned view of a `HistoryItemElided` message. + + Wraps [`::buffa::OwnedView`]`<`[`HistoryItemElidedView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`HistoryItemElidedView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct HistoryItemElidedOwnedView( + ::buffa::OwnedView>, +); +impl HistoryItemElidedOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemElidedOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemElidedOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::HistoryItemElided, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryItemElidedOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`HistoryItemElidedView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &HistoryItemElidedView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::HistoryItemElided { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for HistoryItemElidedOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + HistoryItemElidedOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: HistoryItemElidedOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for HistoryItemElidedOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::HistoryItemElided { + type View<'a> = HistoryItemElidedView<'a>; + type ViewHandle = HistoryItemElidedOwnedView; +} +impl ::serde::Serialize for HistoryItemElidedOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// UserMessageItem is a message from the user. +#[derive(Clone, Debug, Default)] +pub struct UserMessageItemView<'a> { + /// Field 1: `turn_id` + pub turn_id: &'a str, + /// Rendered plain text. Structured and provider-native content is reachable + /// through the artifact surface, not inlined here. + /// + /// Field 2: `text` + pub text: &'a str, + /// The text was shortened for transport. The full content is not recoverable + /// from this response. + /// + /// Field 3: `truncated` + pub truncated: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UserMessageItemView<'a> { + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_text(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UserMessageItemView<'a> { + type Owned = super::super::UserMessageItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UserMessageItem { + turn_id: self.turn_id.to_string(), + text: self.text.to_string(), + truncated: self.truncated, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UserMessageItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.text, buf); + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UserMessageItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("text", self.text)?; + } + { + __map.serialize_entry("truncated", &self.truncated)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UserMessageItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "UserMessageItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.UserMessageItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UserMessageItem"; +} +::buffa::impl_default_view_instance!(UserMessageItemView); +::buffa::impl_view_reborrow!(UserMessageItemView); +/** Self-contained, `'static` owned view of a `UserMessageItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`UserMessageItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UserMessageItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UserMessageItemOwnedView(::buffa::OwnedView>); +impl UserMessageItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UserMessageItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UserMessageItemOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UserMessageItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UserMessageItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`UserMessageItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UserMessageItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UserMessageItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Rendered plain text. Structured and provider-native content is reachable + /// through the artifact surface, not inlined here. + /// + /// Field 2: `text` + #[must_use] + pub fn text(&self) -> &'_ str { + self.0.reborrow().text + } + /// The text was shortened for transport. The full content is not recoverable + /// from this response. + /// + /// Field 3: `truncated` + #[must_use] + pub fn truncated(&self) -> bool { + self.0.reborrow().truncated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for UserMessageItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + UserMessageItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UserMessageItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for UserMessageItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UserMessageItem { + type View<'a> = UserMessageItemView<'a>; + type ViewHandle = UserMessageItemOwnedView; +} +impl ::serde::Serialize for UserMessageItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// AssistantMessageItem is one assistant generation and its outcome. +/// +/// It carries a terminal state rather than a completion flag, because a +/// generation that was interrupted is a different fact from one still running, +/// and a boolean cannot hold that difference. +#[derive(Clone, Debug, Default)] +pub struct AssistantMessageItemView<'a> { + /// Field 1: `turn_id` + pub turn_id: &'a str, + /// Field 2: `model` + pub model: &'a str, + /// Field 3: `text` + pub text: &'a str, + /// Field 4: `truncated` + pub truncated: bool, + /// Field 5: `outcome` + pub outcome: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> AssistantMessageItemView<'a> { + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `model` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_model(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_text(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `outcome` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for AssistantMessageItemView<'a> { + type Owned = super::super::AssistantMessageItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.model = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::AssistantMessageItem, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::AssistantMessageItem, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::AssistantMessageItem { + turn_id: self.turn_id.to_string(), + model: self.model.to_string(), + text: self.text.to_string(), + truncated: self.truncated, + outcome: self.outcome, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for AssistantMessageItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.model) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.model, buf); + ::buffa::types::put_string_field(3u32, &self.text, buf); + ::buffa::types::put_bool_field(4u32, self.truncated, buf); + ::buffa::types::put_int32_field(5u32, self.outcome.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for AssistantMessageItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("model", self.model)?; + } + { + __map.serialize_entry("text", self.text)?; + } + { + __map.serialize_entry("truncated", &self.truncated)?; + } + { + __map.serialize_entry("outcome", &self.outcome)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for AssistantMessageItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "AssistantMessageItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem"; +} +::buffa::impl_default_view_instance!(AssistantMessageItemView); +::buffa::impl_view_reborrow!(AssistantMessageItemView); +/** Self-contained, `'static` owned view of a `AssistantMessageItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`AssistantMessageItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`AssistantMessageItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct AssistantMessageItemOwnedView( + ::buffa::OwnedView>, +); +impl AssistantMessageItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AssistantMessageItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AssistantMessageItemOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::AssistantMessageItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + AssistantMessageItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`AssistantMessageItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &AssistantMessageItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::AssistantMessageItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 2: `model` + #[must_use] + pub fn model(&self) -> &'_ str { + self.0.reborrow().model + } + /// Field 3: `text` + #[must_use] + pub fn text(&self) -> &'_ str { + self.0.reborrow().text + } + /// Field 4: `truncated` + #[must_use] + pub fn truncated(&self) -> bool { + self.0.reborrow().truncated + } + /// Field 5: `outcome` + #[must_use] + pub fn outcome(&self) -> ::buffa::EnumValue { + self.0.reborrow().outcome + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for AssistantMessageItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + AssistantMessageItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: AssistantMessageItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for AssistantMessageItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::AssistantMessageItem { + type View<'a> = AssistantMessageItemView<'a>; + type ViewHandle = AssistantMessageItemOwnedView; +} +impl ::serde::Serialize for AssistantMessageItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ToolCallItem is one tool call and its lifecycle position. +#[derive(Clone, Debug, Default)] +pub struct ToolCallItemView<'a> { + /// Field 1: `turn_id` + pub turn_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_name` + pub tool_name: &'a str, + /// Field 4: `outcome` + pub outcome: ::buffa::EnumValue, + /// True when the call started and no terminal outcome was ever recorded. This + /// is the reader-visible form of an interrupted call awaiting reconciliation. + /// + /// Field 5: `unreconciled` + pub unreconciled: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ToolCallItemView<'a> { + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_name` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_name(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `outcome` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `unreconciled` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_unreconciled(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ToolCallItemView<'a> { + type Owned = super::super::ToolCallItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_name = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.unreconciled = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ToolCallItem { + turn_id: self.turn_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_name: self.tool_name.to_string(), + outcome: self.outcome, + unreconciled: self.unreconciled, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ToolCallItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_name, buf); + ::buffa::types::put_int32_field(4u32, self.outcome.to_i32(), buf); + ::buffa::types::put_bool_field(5u32, self.unreconciled, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ToolCallItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolName", self.tool_name)?; + } + { + __map.serialize_entry("outcome", &self.outcome)?; + } + { + __map.serialize_entry("unreconciled", &self.unreconciled)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ToolCallItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ToolCallItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ToolCallItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ToolCallItem"; +} +::buffa::impl_default_view_instance!(ToolCallItemView); +::buffa::impl_view_reborrow!(ToolCallItemView); +/** Self-contained, `'static` owned view of a `ToolCallItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`ToolCallItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ToolCallItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ToolCallItemOwnedView(::buffa::OwnedView>); +impl ToolCallItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ToolCallItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ToolCallItemOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ToolCallItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ToolCallItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ToolCallItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ToolCallItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ToolCallItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_name` + #[must_use] + pub fn tool_name(&self) -> &'_ str { + self.0.reborrow().tool_name + } + /// Field 4: `outcome` + #[must_use] + pub fn outcome(&self) -> ::buffa::EnumValue { + self.0.reborrow().outcome + } + /// True when the call started and no terminal outcome was ever recorded. This + /// is the reader-visible form of an interrupted call awaiting reconciliation. + /// + /// Field 5: `unreconciled` + #[must_use] + pub fn unreconciled(&self) -> bool { + self.0.reborrow().unreconciled + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ToolCallItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ToolCallItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ToolCallItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ToolCallItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ToolCallItem { + type View<'a> = ToolCallItemView<'a>; + type ViewHandle = ToolCallItemOwnedView; +} +impl ::serde::Serialize for ToolCallItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// FileChangeItem is one workspace file change attributed to a tool call. +#[derive(Clone, Debug, Default)] +pub struct FileChangeItemView<'a> { + /// Field 1: `turn_id` + pub turn_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 3: `path` + pub path: &'a str, + /// Field 4: `change_kind` + pub change_kind: ::buffa::EnumValue, + /// Set only for a rename. + /// + /// Field 5: `previous_path` + pub previous_path: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> FileChangeItemView<'a> { + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `path` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_path(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `change_kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_change_kind(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for FileChangeItemView<'a> { + type Owned = super::super::FileChangeItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.path = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.change_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.previous_path = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::FileChangeItem { + turn_id: self.turn_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + path: self.path.to_string(), + change_kind: self.change_kind, + previous_path: self.previous_path.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for FileChangeItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + { + let val = self.change_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.previous_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.path, buf); + ::buffa::types::put_int32_field(4u32, self.change_kind.to_i32(), buf); + if let Some(ref v) = self.previous_path { + ::buffa::types::put_string_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for FileChangeItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("path", self.path)?; + } + { + __map.serialize_entry("changeKind", &self.change_kind)?; + } + if let ::core::option::Option::Some(__v) = self.previous_path { + __map.serialize_entry("previousPath", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for FileChangeItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "FileChangeItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.FileChangeItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.FileChangeItem"; +} +::buffa::impl_default_view_instance!(FileChangeItemView); +::buffa::impl_view_reborrow!(FileChangeItemView); +/** Self-contained, `'static` owned view of a `FileChangeItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`FileChangeItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FileChangeItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct FileChangeItemOwnedView(::buffa::OwnedView>); +impl FileChangeItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FileChangeItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FileChangeItemOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::FileChangeItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FileChangeItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`FileChangeItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &FileChangeItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::FileChangeItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 3: `path` + #[must_use] + pub fn path(&self) -> &'_ str { + self.0.reborrow().path + } + /// Field 4: `change_kind` + #[must_use] + pub fn change_kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().change_kind + } + /// Set only for a rename. + /// + /// Field 5: `previous_path` + #[must_use] + pub fn previous_path(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().previous_path + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for FileChangeItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + FileChangeItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: FileChangeItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for FileChangeItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::FileChangeItem { + type View<'a> = FileChangeItemView<'a>; + type ViewHandle = FileChangeItemOwnedView; +} +impl ::serde::Serialize for FileChangeItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SystemNoticeItem is a system-originated notice surfaced in the transcript. +#[derive(Clone, Debug, Default)] +pub struct SystemNoticeItemView<'a> { + /// Field 1: `level` + pub level: ::buffa::EnumValue, + /// Field 2: `text` + pub text: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SystemNoticeItemView<'a> { + /**Whether required field `level` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_level(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_text(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SystemNoticeItemView<'a> { + type Owned = super::super::SystemNoticeItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.level = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SystemNoticeItem { + level: self.level, + text: self.text.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SystemNoticeItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.level.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.level.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.text, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SystemNoticeItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("level", &self.level)?; + } + { + __map.serialize_entry("text", self.text)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SystemNoticeItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SystemNoticeItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem"; +} +::buffa::impl_default_view_instance!(SystemNoticeItemView); +::buffa::impl_view_reborrow!(SystemNoticeItemView); +/** Self-contained, `'static` owned view of a `SystemNoticeItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`SystemNoticeItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SystemNoticeItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SystemNoticeItemOwnedView(::buffa::OwnedView>); +impl SystemNoticeItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SystemNoticeItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SystemNoticeItemOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SystemNoticeItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SystemNoticeItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SystemNoticeItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SystemNoticeItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SystemNoticeItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `level` + #[must_use] + pub fn level(&self) -> ::buffa::EnumValue { + self.0.reborrow().level + } + /// Field 2: `text` + #[must_use] + pub fn text(&self) -> &'_ str { + self.0.reborrow().text + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SystemNoticeItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SystemNoticeItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SystemNoticeItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SystemNoticeItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SystemNoticeItem { + type View<'a> = SystemNoticeItemView<'a>; + type ViewHandle = SystemNoticeItemOwnedView; +} +impl ::serde::Serialize for SystemNoticeItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// CompactionItem marks where a range of history was replaced by a summary. +/// +/// It is surfaced rather than hidden so a reader can see that the transcript it +/// is looking at is not the whole transcript. +#[derive(Clone, Debug, Default)] +pub struct CompactionItemView<'a> { + /// Inclusive ordinal range this summary stands in for. + /// + /// Field 1: `covers_from` + pub covers_from: u64, + /// Field 2: `covers_through` + pub covers_through: u64, + /// Field 3: `summary_text` + pub summary_text: &'a str, + /// Field 4: `truncated` + pub truncated: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CompactionItemView<'a> { + /**Whether required field `covers_from` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_from(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `covers_through` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_through(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `summary_text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary_text(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CompactionItemView<'a> { + type Owned = super::super::CompactionItem; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.covers_from = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.covers_through = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.summary_text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CompactionItem { + covers_from: self.covers_from, + covers_through: self.covers_through, + summary_text: self.summary_text.to_string(), + truncated: self.truncated, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CompactionItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.covers_from) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.covers_through) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.covers_from, buf); + ::buffa::types::put_uint64_field(2u32, self.covers_through, buf); + ::buffa::types::put_string_field(3u32, &self.summary_text, buf); + ::buffa::types::put_bool_field(4u32, self.truncated, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CompactionItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "coversFrom", + &::buffa::json_helpers::ProtoJson(&self.covers_from), + )?; + } + { + __map + .serialize_entry( + "coversThrough", + &::buffa::json_helpers::ProtoJson(&self.covers_through), + )?; + } + { + __map.serialize_entry("summaryText", self.summary_text)?; + } + { + __map.serialize_entry("truncated", &self.truncated)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CompactionItemView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CompactionItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CompactionItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CompactionItem"; +} +::buffa::impl_default_view_instance!(CompactionItemView); +::buffa::impl_view_reborrow!(CompactionItemView); +/** Self-contained, `'static` owned view of a `CompactionItem` message. + + Wraps [`::buffa::OwnedView`]`<`[`CompactionItemView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CompactionItemView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CompactionItemOwnedView(::buffa::OwnedView>); +impl CompactionItemOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionItemOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionItemOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CompactionItem, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionItemOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CompactionItemView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CompactionItemView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CompactionItem { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Inclusive ordinal range this summary stands in for. + /// + /// Field 1: `covers_from` + #[must_use] + pub fn covers_from(&self) -> u64 { + self.0.reborrow().covers_from + } + /// Field 2: `covers_through` + #[must_use] + pub fn covers_through(&self) -> u64 { + self.0.reborrow().covers_through + } + /// Field 3: `summary_text` + #[must_use] + pub fn summary_text(&self) -> &'_ str { + self.0.reborrow().summary_text + } + /// Field 4: `truncated` + #[must_use] + pub fn truncated(&self) -> bool { + self.0.reborrow().truncated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CompactionItemOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CompactionItemOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CompactionItemOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CompactionItemOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CompactionItem { + type View<'a> = CompactionItemView<'a>; + type ViewHandle = CompactionItemOwnedView; +} +impl ::serde::Serialize for CompactionItemOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view_oneof.rs new file mode 100644 index 0000000000..4d23b8d052 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.__view_oneof.rs @@ -0,0 +1,45 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/history_item.proto + +pub mod history_item { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Item<'a> { + UserMessage( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::UserMessageItemView<'a>, + >, + ), + AssistantMessage( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::AssistantMessageItemView<'a>, + >, + ), + ToolCall( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::ToolCallItemView<'a>, + >, + ), + FileChange( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::FileChangeItemView<'a>, + >, + ), + SystemNotice( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::SystemNoticeItemView<'a>, + >, + ), + Compaction( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::CompactionItemView<'a>, + >, + ), + Elided( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::HistoryItemElidedView<'a>, + >, + ), + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.rs new file mode 100644 index 0000000000..9214a5e2eb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.history_item.rs @@ -0,0 +1,2884 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/history_item.proto + +/// HistoryItemKind is what an item is, readable without decoding the union. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum HistoryItemKind { + HISTORY_ITEM_KIND_UNSPECIFIED = 0i32, + HISTORY_ITEM_KIND_USER_MESSAGE = 1i32, + HISTORY_ITEM_KIND_ASSISTANT_MESSAGE = 2i32, + HISTORY_ITEM_KIND_TOOL_CALL = 3i32, + HISTORY_ITEM_KIND_FILE_CHANGE = 4i32, + HISTORY_ITEM_KIND_SYSTEM_NOTICE = 5i32, + HISTORY_ITEM_KIND_COMPACTION = 6i32, + /// The item exists but was not rendered. `elided` says why. + HISTORY_ITEM_KIND_ELIDED = 7i32, +} +impl HistoryItemKind { + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::HISTORY_ITEM_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_USER_MESSAGE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UserMessage: Self = Self::HISTORY_ITEM_KIND_USER_MESSAGE; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AssistantMessage: Self = Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_TOOL_CALL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ToolCall: Self = Self::HISTORY_ITEM_KIND_TOOL_CALL; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_FILE_CHANGE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const FileChange: Self = Self::HISTORY_ITEM_KIND_FILE_CHANGE; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SystemNotice: Self = Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_COMPACTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Compaction: Self = Self::HISTORY_ITEM_KIND_COMPACTION; + ///Idiomatic alias for [`Self::HISTORY_ITEM_KIND_ELIDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Elided: Self = Self::HISTORY_ITEM_KIND_ELIDED; +} +impl ::core::default::Default for HistoryItemKind { + fn default() -> Self { + Self::HISTORY_ITEM_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for HistoryItemKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for HistoryItemKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = HistoryItemKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(HistoryItemKind) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for HistoryItemKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for HistoryItemKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_USER_MESSAGE), + 2i32 => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE) + } + 3i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_TOOL_CALL), + 4i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_FILE_CHANGE), + 5i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE), + 6i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_COMPACTION), + 7i32 => ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_ELIDED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::HISTORY_ITEM_KIND_UNSPECIFIED => "HISTORY_ITEM_KIND_UNSPECIFIED", + Self::HISTORY_ITEM_KIND_USER_MESSAGE => "HISTORY_ITEM_KIND_USER_MESSAGE", + Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE => { + "HISTORY_ITEM_KIND_ASSISTANT_MESSAGE" + } + Self::HISTORY_ITEM_KIND_TOOL_CALL => "HISTORY_ITEM_KIND_TOOL_CALL", + Self::HISTORY_ITEM_KIND_FILE_CHANGE => "HISTORY_ITEM_KIND_FILE_CHANGE", + Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE => "HISTORY_ITEM_KIND_SYSTEM_NOTICE", + Self::HISTORY_ITEM_KIND_COMPACTION => "HISTORY_ITEM_KIND_COMPACTION", + Self::HISTORY_ITEM_KIND_ELIDED => "HISTORY_ITEM_KIND_ELIDED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "HISTORY_ITEM_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_UNSPECIFIED) + } + "HISTORY_ITEM_KIND_USER_MESSAGE" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_USER_MESSAGE) + } + "HISTORY_ITEM_KIND_ASSISTANT_MESSAGE" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE) + } + "HISTORY_ITEM_KIND_TOOL_CALL" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_TOOL_CALL) + } + "HISTORY_ITEM_KIND_FILE_CHANGE" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_FILE_CHANGE) + } + "HISTORY_ITEM_KIND_SYSTEM_NOTICE" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE) + } + "HISTORY_ITEM_KIND_COMPACTION" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_COMPACTION) + } + "HISTORY_ITEM_KIND_ELIDED" => { + ::core::option::Option::Some(Self::HISTORY_ITEM_KIND_ELIDED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::HISTORY_ITEM_KIND_UNSPECIFIED, + Self::HISTORY_ITEM_KIND_USER_MESSAGE, + Self::HISTORY_ITEM_KIND_ASSISTANT_MESSAGE, + Self::HISTORY_ITEM_KIND_TOOL_CALL, + Self::HISTORY_ITEM_KIND_FILE_CHANGE, + Self::HISTORY_ITEM_KIND_SYSTEM_NOTICE, + Self::HISTORY_ITEM_KIND_COMPACTION, + Self::HISTORY_ITEM_KIND_ELIDED, + ] + } +} +/// ElisionReason is why an item was withheld. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ElisionReason { + ELISION_REASON_UNSPECIFIED = 0i32, + /// The item needs a variant introduced after the caller's contract minor. + /// Upgrading the caller resolves it. + ELISION_REASON_CONTRACT_CLAMPED = 1i32, + /// A redaction masked the item's content. The item's existence is still a + /// fact; only the content is gone. + ELISION_REASON_REDACTED = 2i32, + /// The caller is not authorized to see this item's content. + ELISION_REASON_NOT_AUTHORIZED = 3i32, +} +impl ElisionReason { + ///Idiomatic alias for [`Self::ELISION_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ELISION_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::ELISION_REASON_CONTRACT_CLAMPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ContractClamped: Self = Self::ELISION_REASON_CONTRACT_CLAMPED; + ///Idiomatic alias for [`Self::ELISION_REASON_REDACTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Redacted: Self = Self::ELISION_REASON_REDACTED; + ///Idiomatic alias for [`Self::ELISION_REASON_NOT_AUTHORIZED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotAuthorized: Self = Self::ELISION_REASON_NOT_AUTHORIZED; +} +impl ::core::default::Default for ElisionReason { + fn default() -> Self { + Self::ELISION_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for ElisionReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ElisionReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ElisionReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(ElisionReason)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ElisionReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ElisionReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ELISION_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ELISION_REASON_CONTRACT_CLAMPED), + 2i32 => ::core::option::Option::Some(Self::ELISION_REASON_REDACTED), + 3i32 => ::core::option::Option::Some(Self::ELISION_REASON_NOT_AUTHORIZED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ELISION_REASON_UNSPECIFIED => "ELISION_REASON_UNSPECIFIED", + Self::ELISION_REASON_CONTRACT_CLAMPED => "ELISION_REASON_CONTRACT_CLAMPED", + Self::ELISION_REASON_REDACTED => "ELISION_REASON_REDACTED", + Self::ELISION_REASON_NOT_AUTHORIZED => "ELISION_REASON_NOT_AUTHORIZED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ELISION_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ELISION_REASON_UNSPECIFIED) + } + "ELISION_REASON_CONTRACT_CLAMPED" => { + ::core::option::Option::Some(Self::ELISION_REASON_CONTRACT_CLAMPED) + } + "ELISION_REASON_REDACTED" => { + ::core::option::Option::Some(Self::ELISION_REASON_REDACTED) + } + "ELISION_REASON_NOT_AUTHORIZED" => { + ::core::option::Option::Some(Self::ELISION_REASON_NOT_AUTHORIZED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ELISION_REASON_UNSPECIFIED, + Self::ELISION_REASON_CONTRACT_CLAMPED, + Self::ELISION_REASON_REDACTED, + Self::ELISION_REASON_NOT_AUTHORIZED, + ] + } +} +/// AssistantMessageOutcome is how a generation ended. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum AssistantMessageOutcome { + ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED = 0i32, + /// Started, with no terminal fact recorded. Either still running or stranded + /// by a crash; the reader cannot tell which, and must not present it as done. + ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT = 1i32, + ASSISTANT_MESSAGE_OUTCOME_COMPLETED = 2i32, + ASSISTANT_MESSAGE_OUTCOME_FAILED = 3i32, +} +impl AssistantMessageOutcome { + ///Idiomatic alias for [`Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED; + ///Idiomatic alias for [`Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InFlight: Self = Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT; + ///Idiomatic alias for [`Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Completed: Self = Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED; + ///Idiomatic alias for [`Self::ASSISTANT_MESSAGE_OUTCOME_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::ASSISTANT_MESSAGE_OUTCOME_FAILED; +} +impl ::core::default::Default for AssistantMessageOutcome { + fn default() -> Self { + Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED + } +} +impl ::serde::Serialize for AssistantMessageOutcome { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for AssistantMessageOutcome { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = AssistantMessageOutcome; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(AssistantMessageOutcome) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for AssistantMessageOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for AssistantMessageOutcome { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED) + } + 1i32 => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT) + } + 2i32 => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED) + } + 3i32 => ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_FAILED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED => { + "ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED" + } + Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT => { + "ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT" + } + Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED => { + "ASSISTANT_MESSAGE_OUTCOME_COMPLETED" + } + Self::ASSISTANT_MESSAGE_OUTCOME_FAILED => "ASSISTANT_MESSAGE_OUTCOME_FAILED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED) + } + "ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT" => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT) + } + "ASSISTANT_MESSAGE_OUTCOME_COMPLETED" => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED) + } + "ASSISTANT_MESSAGE_OUTCOME_FAILED" => { + ::core::option::Option::Some(Self::ASSISTANT_MESSAGE_OUTCOME_FAILED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ASSISTANT_MESSAGE_OUTCOME_UNSPECIFIED, + Self::ASSISTANT_MESSAGE_OUTCOME_IN_FLIGHT, + Self::ASSISTANT_MESSAGE_OUTCOME_COMPLETED, + Self::ASSISTANT_MESSAGE_OUTCOME_FAILED, + ] + } +} +/// ToolCallOutcome is where a tool call stopped. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ToolCallOutcome { + TOOL_CALL_OUTCOME_UNSPECIFIED = 0i32, + TOOL_CALL_OUTCOME_REQUESTED = 1i32, + TOOL_CALL_OUTCOME_APPROVED = 2i32, + TOOL_CALL_OUTCOME_DENIED = 3i32, + /// Running, or stranded by a crash. See `unreconciled`. + TOOL_CALL_OUTCOME_STARTED = 4i32, + TOOL_CALL_OUTCOME_COMPLETED = 5i32, + TOOL_CALL_OUTCOME_FAILED = 6i32, +} +impl ToolCallOutcome { + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TOOL_CALL_OUTCOME_UNSPECIFIED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_REQUESTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Requested: Self = Self::TOOL_CALL_OUTCOME_REQUESTED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_APPROVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Approved: Self = Self::TOOL_CALL_OUTCOME_APPROVED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Denied: Self = Self::TOOL_CALL_OUTCOME_DENIED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_STARTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Started: Self = Self::TOOL_CALL_OUTCOME_STARTED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_COMPLETED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Completed: Self = Self::TOOL_CALL_OUTCOME_COMPLETED; + ///Idiomatic alias for [`Self::TOOL_CALL_OUTCOME_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::TOOL_CALL_OUTCOME_FAILED; +} +impl ::core::default::Default for ToolCallOutcome { + fn default() -> Self { + Self::TOOL_CALL_OUTCOME_UNSPECIFIED + } +} +impl ::serde::Serialize for ToolCallOutcome { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ToolCallOutcome { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ToolCallOutcome; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ToolCallOutcome) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ToolCallOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ToolCallOutcome { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_REQUESTED), + 2i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_APPROVED), + 3i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_DENIED), + 4i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_STARTED), + 5i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_COMPLETED), + 6i32 => ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_FAILED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TOOL_CALL_OUTCOME_UNSPECIFIED => "TOOL_CALL_OUTCOME_UNSPECIFIED", + Self::TOOL_CALL_OUTCOME_REQUESTED => "TOOL_CALL_OUTCOME_REQUESTED", + Self::TOOL_CALL_OUTCOME_APPROVED => "TOOL_CALL_OUTCOME_APPROVED", + Self::TOOL_CALL_OUTCOME_DENIED => "TOOL_CALL_OUTCOME_DENIED", + Self::TOOL_CALL_OUTCOME_STARTED => "TOOL_CALL_OUTCOME_STARTED", + Self::TOOL_CALL_OUTCOME_COMPLETED => "TOOL_CALL_OUTCOME_COMPLETED", + Self::TOOL_CALL_OUTCOME_FAILED => "TOOL_CALL_OUTCOME_FAILED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TOOL_CALL_OUTCOME_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_UNSPECIFIED) + } + "TOOL_CALL_OUTCOME_REQUESTED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_REQUESTED) + } + "TOOL_CALL_OUTCOME_APPROVED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_APPROVED) + } + "TOOL_CALL_OUTCOME_DENIED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_DENIED) + } + "TOOL_CALL_OUTCOME_STARTED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_STARTED) + } + "TOOL_CALL_OUTCOME_COMPLETED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_COMPLETED) + } + "TOOL_CALL_OUTCOME_FAILED" => { + ::core::option::Option::Some(Self::TOOL_CALL_OUTCOME_FAILED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TOOL_CALL_OUTCOME_UNSPECIFIED, + Self::TOOL_CALL_OUTCOME_REQUESTED, + Self::TOOL_CALL_OUTCOME_APPROVED, + Self::TOOL_CALL_OUTCOME_DENIED, + Self::TOOL_CALL_OUTCOME_STARTED, + Self::TOOL_CALL_OUTCOME_COMPLETED, + Self::TOOL_CALL_OUTCOME_FAILED, + ] + } +} +/// FileChangeKindView is what happened to a file. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum FileChangeKindView { + FILE_CHANGE_KIND_VIEW_UNSPECIFIED = 0i32, + FILE_CHANGE_KIND_VIEW_CREATED = 1i32, + FILE_CHANGE_KIND_VIEW_MODIFIED = 2i32, + FILE_CHANGE_KIND_VIEW_DELETED = 3i32, + FILE_CHANGE_KIND_VIEW_RENAMED = 4i32, +} +impl FileChangeKindView { + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED; + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_VIEW_CREATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Created: Self = Self::FILE_CHANGE_KIND_VIEW_CREATED; + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_VIEW_MODIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Modified: Self = Self::FILE_CHANGE_KIND_VIEW_MODIFIED; + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_VIEW_DELETED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Deleted: Self = Self::FILE_CHANGE_KIND_VIEW_DELETED; + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_VIEW_RENAMED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Renamed: Self = Self::FILE_CHANGE_KIND_VIEW_RENAMED; +} +impl ::core::default::Default for FileChangeKindView { + fn default() -> Self { + Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED + } +} +impl ::serde::Serialize for FileChangeKindView { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for FileChangeKindView { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = FileChangeKindView; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(FileChangeKindView) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for FileChangeKindView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for FileChangeKindView { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_CREATED), + 2i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_MODIFIED), + 3i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_DELETED), + 4i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_RENAMED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED => { + "FILE_CHANGE_KIND_VIEW_UNSPECIFIED" + } + Self::FILE_CHANGE_KIND_VIEW_CREATED => "FILE_CHANGE_KIND_VIEW_CREATED", + Self::FILE_CHANGE_KIND_VIEW_MODIFIED => "FILE_CHANGE_KIND_VIEW_MODIFIED", + Self::FILE_CHANGE_KIND_VIEW_DELETED => "FILE_CHANGE_KIND_VIEW_DELETED", + Self::FILE_CHANGE_KIND_VIEW_RENAMED => "FILE_CHANGE_KIND_VIEW_RENAMED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "FILE_CHANGE_KIND_VIEW_UNSPECIFIED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED) + } + "FILE_CHANGE_KIND_VIEW_CREATED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_CREATED) + } + "FILE_CHANGE_KIND_VIEW_MODIFIED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_MODIFIED) + } + "FILE_CHANGE_KIND_VIEW_DELETED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_DELETED) + } + "FILE_CHANGE_KIND_VIEW_RENAMED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_VIEW_RENAMED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::FILE_CHANGE_KIND_VIEW_UNSPECIFIED, + Self::FILE_CHANGE_KIND_VIEW_CREATED, + Self::FILE_CHANGE_KIND_VIEW_MODIFIED, + Self::FILE_CHANGE_KIND_VIEW_DELETED, + Self::FILE_CHANGE_KIND_VIEW_RENAMED, + ] + } +} +/// NoticeLevelView is a notice's severity. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum NoticeLevelView { + NOTICE_LEVEL_VIEW_UNSPECIFIED = 0i32, + NOTICE_LEVEL_VIEW_INFO = 1i32, + NOTICE_LEVEL_VIEW_WARNING = 2i32, + NOTICE_LEVEL_VIEW_ERROR = 3i32, +} +impl NoticeLevelView { + ///Idiomatic alias for [`Self::NOTICE_LEVEL_VIEW_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::NOTICE_LEVEL_VIEW_UNSPECIFIED; + ///Idiomatic alias for [`Self::NOTICE_LEVEL_VIEW_INFO`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Info: Self = Self::NOTICE_LEVEL_VIEW_INFO; + ///Idiomatic alias for [`Self::NOTICE_LEVEL_VIEW_WARNING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Warning: Self = Self::NOTICE_LEVEL_VIEW_WARNING; + ///Idiomatic alias for [`Self::NOTICE_LEVEL_VIEW_ERROR`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Error: Self = Self::NOTICE_LEVEL_VIEW_ERROR; +} +impl ::core::default::Default for NoticeLevelView { + fn default() -> Self { + Self::NOTICE_LEVEL_VIEW_UNSPECIFIED + } +} +impl ::serde::Serialize for NoticeLevelView { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for NoticeLevelView { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = NoticeLevelView; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(NoticeLevelView) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for NoticeLevelView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for NoticeLevelView { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_INFO), + 2i32 => ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_WARNING), + 3i32 => ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_ERROR), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::NOTICE_LEVEL_VIEW_UNSPECIFIED => "NOTICE_LEVEL_VIEW_UNSPECIFIED", + Self::NOTICE_LEVEL_VIEW_INFO => "NOTICE_LEVEL_VIEW_INFO", + Self::NOTICE_LEVEL_VIEW_WARNING => "NOTICE_LEVEL_VIEW_WARNING", + Self::NOTICE_LEVEL_VIEW_ERROR => "NOTICE_LEVEL_VIEW_ERROR", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "NOTICE_LEVEL_VIEW_UNSPECIFIED" => { + ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_UNSPECIFIED) + } + "NOTICE_LEVEL_VIEW_INFO" => { + ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_INFO) + } + "NOTICE_LEVEL_VIEW_WARNING" => { + ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_WARNING) + } + "NOTICE_LEVEL_VIEW_ERROR" => { + ::core::option::Option::Some(Self::NOTICE_LEVEL_VIEW_ERROR) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::NOTICE_LEVEL_VIEW_UNSPECIFIED, + Self::NOTICE_LEVEL_VIEW_INFO, + Self::NOTICE_LEVEL_VIEW_WARNING, + Self::NOTICE_LEVEL_VIEW_ERROR, + ] + } +} +/// HistoryItem is one entry in a session's reader-visible history. +/// +/// The discriminated-union hazard this shape is built around: a caller decoding +/// a `oneof` arm added after its contract minor sees an unset `oneof` and cannot +/// distinguish "a variant I do not know" from "a variant that was not set". +/// Silently rendering nothing for a real event is a correctness failure, not a +/// cosmetic one. +/// +/// Two mechanisms close that gap: +/// +/// 1. `kind` is a plain enum outside the `oneof`. Proto enums are open, so an +/// ```text +/// unrecognized kind decodes as its raw number rather than vanishing, and a +/// caller can always tell that something is here it does not understand. +/// ``` +/// 2. The server clamps to the caller's declared contract minor and emits +/// ```text +/// HISTORY_ITEM_KIND_ELIDED with an `elided` payload rather than a variant +/// the caller cannot decode. Elision is affirmative: the caller reads that +/// an item was withheld instead of inferring it from an empty field. +/// ``` +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct HistoryItem { + /// Stable within a session, opaque, and safe to use as a rendering key. It + /// remains stable across an elision, so a client that upgrades sees the same + /// item resolve to a real variant. + /// + /// Field 1: `item_id` + #[serde( + rename = "itemId", + alias = "item_id", + with = "::buffa::json_helpers::proto_string" + )] + pub item_id: ::buffa::alloc::string::String, + /// The session's own 1-indexed position for this item. + /// + /// Field 2: `ordinal` + #[serde(rename = "ordinal", with = "::buffa::json_helpers::uint64")] + pub ordinal: u64, + /// Set even when the matching `item` arm is absent, so an unknown or withheld + /// item is still identifiable. + /// + /// Field 3: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + #[serde(flatten)] + pub item: ::core::option::Option<__buffa::oneof::history_item::Item>, +} +impl ::core::fmt::Debug for HistoryItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HistoryItem") + .field("item_id", &self.item_id) + .field("ordinal", &self.ordinal) + .field("kind", &self.kind) + .field("item", &self.item) + .finish() + } +} +impl HistoryItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItem"; +} +::buffa::impl_default_instance!(HistoryItem); +impl ::buffa::MessageName for HistoryItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItem"; +} +impl ::buffa::Message for HistoryItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.item_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let ::core::option::Option::Some(ref v) = self.item { + match v { + __buffa::oneof::history_item::Item::UserMessage(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::AssistantMessage(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::ToolCall(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::FileChange(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::SystemNotice(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::Compaction(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::history_item::Item::Elided(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.item_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + ::buffa::types::put_int32_field(3u32, self.kind.to_i32(), buf); + if let ::core::option::Option::Some(ref v) = self.item { + match v { + __buffa::oneof::history_item::Item::UserMessage(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::AssistantMessage(x) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::ToolCall(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::FileChange(x) => { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::SystemNotice(x) => { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::Compaction(x) => { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::history_item::Item::Elided(x) => { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.item_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::UserMessage(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::UserMessage( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::AssistantMessage( + ref mut existing, + ), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::AssistantMessage( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::ToolCall(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::ToolCall( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::FileChange(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::FileChange( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::SystemNotice(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::SystemNotice( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::Compaction(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::Compaction( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::history_item::Item::Elided(ref mut existing), + ) = self.item + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.item = ::core::option::Option::Some( + __buffa::oneof::history_item::Item::Elided( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.item_id.clear(); + self.ordinal = 0u64; + self.kind = ::buffa::EnumValue::from(0); + self.item = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for HistoryItem { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = HistoryItem; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct HistoryItem") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __f_item_id: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __f_ordinal: ::core::option::Option = None; + let mut __f_kind: ::core::option::Option< + ::buffa::EnumValue, + > = None; + let mut __oneof_item: ::core::option::Option< + __buffa::oneof::history_item::Item, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "itemId" | "item_id" => { + __f_item_id = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "ordinal" => { + __f_ordinal = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = u64; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result { + ::buffa::json_helpers::uint64::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "kind" => { + __f_kind = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::EnumValue; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::EnumValue, + D::Error, + > { + ::buffa::json_helpers::proto_enum::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "userMessage" | "user_message" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + UserMessageItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::UserMessage( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "assistantMessage" | "assistant_message" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + AssistantMessageItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::AssistantMessage( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "toolCall" | "tool_call" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + ToolCallItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::ToolCall( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "fileChange" | "file_change" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + FileChangeItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::FileChange( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "systemNotice" | "system_notice" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + SystemNoticeItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::SystemNotice( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "compaction" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + CompactionItem, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::Compaction( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "elided" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + HistoryItemElided, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_item.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'item'", + ), + ); + } + __oneof_item = Some( + __buffa::oneof::history_item::Item::Elided( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + if let ::core::option::Option::Some(v) = __f_item_id { + __r.item_id = v; + } + if let ::core::option::Option::Some(v) = __f_ordinal { + __r.ordinal = v; + } + if let ::core::option::Option::Some(v) = __f_kind { + __r.kind = v; + } + __r.item = __oneof_item; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for HistoryItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HISTORY_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod history_item { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::__buffa::oneof::history_item::Item; + #[doc(inline)] + pub use super::__buffa::view::oneof::history_item::Item as ItemView; +} +/// HistoryItemElided is an item the server chose not to render, stated +/// affirmatively so a caller never mistakes a withheld item for a missing one. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct HistoryItemElided { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for HistoryItemElided { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HistoryItemElided").field("reason", &self.reason).finish() + } +} +impl HistoryItemElided { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItemElided"; +} +::buffa::impl_default_instance!(HistoryItemElided); +impl ::buffa::MessageName for HistoryItemElided { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryItemElided"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryItemElided"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItemElided"; +} +impl ::buffa::Message for HistoryItemElided { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for HistoryItemElided { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HISTORY_ITEM_ELIDED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryItemElided", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// UserMessageItem is a message from the user. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UserMessageItem { + /// Field 1: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Rendered plain text. Structured and provider-native content is reachable + /// through the artifact surface, not inlined here. + /// + /// Field 2: `text` + #[serde(rename = "text", with = "::buffa::json_helpers::proto_string")] + pub text: ::buffa::alloc::string::String, + /// The text was shortened for transport. The full content is not recoverable + /// from this response. + /// + /// Field 3: `truncated` + #[serde(rename = "truncated", with = "::buffa::json_helpers::proto_bool")] + pub truncated: bool, +} +impl ::core::fmt::Debug for UserMessageItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UserMessageItem") + .field("turn_id", &self.turn_id) + .field("text", &self.text) + .field("truncated", &self.truncated) + .finish() + } +} +impl UserMessageItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UserMessageItem"; +} +::buffa::impl_default_instance!(UserMessageItem); +impl ::buffa::MessageName for UserMessageItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "UserMessageItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.UserMessageItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UserMessageItem"; +} +impl ::buffa::Message for UserMessageItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.text, buf); + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.text, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.truncated = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.turn_id.clear(); + self.text.clear(); + self.truncated = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for UserMessageItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __USER_MESSAGE_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UserMessageItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// AssistantMessageItem is one assistant generation and its outcome. +/// +/// It carries a terminal state rather than a completion flag, because a +/// generation that was interrupted is a different fact from one still running, +/// and a boolean cannot hold that difference. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct AssistantMessageItem { + /// Field 1: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 2: `model` + #[serde(rename = "model", with = "::buffa::json_helpers::proto_string")] + pub model: ::buffa::alloc::string::String, + /// Field 3: `text` + #[serde(rename = "text", with = "::buffa::json_helpers::proto_string")] + pub text: ::buffa::alloc::string::String, + /// Field 4: `truncated` + #[serde(rename = "truncated", with = "::buffa::json_helpers::proto_bool")] + pub truncated: bool, + /// Field 5: `outcome` + #[serde(rename = "outcome", with = "::buffa::json_helpers::proto_enum")] + pub outcome: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for AssistantMessageItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AssistantMessageItem") + .field("turn_id", &self.turn_id) + .field("model", &self.model) + .field("text", &self.text) + .field("truncated", &self.truncated) + .field("outcome", &self.outcome) + .finish() + } +} +impl AssistantMessageItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem"; +} +::buffa::impl_default_instance!(AssistantMessageItem); +impl ::buffa::MessageName for AssistantMessageItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "AssistantMessageItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem"; +} +impl ::buffa::Message for AssistantMessageItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.model) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.model, buf); + ::buffa::types::put_string_field(3u32, &self.text, buf); + ::buffa::types::put_bool_field(4u32, self.truncated, buf); + ::buffa::types::put_int32_field(5u32, self.outcome.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.model, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.text, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.truncated = ::buffa::types::decode_bool(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.turn_id.clear(); + self.model.clear(); + self.text.clear(); + self.truncated = false; + self.outcome = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for AssistantMessageItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ASSISTANT_MESSAGE_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.AssistantMessageItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ToolCallItem is one tool call and its lifecycle position. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ToolCallItem { + /// Field 1: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_name` + #[serde( + rename = "toolName", + alias = "tool_name", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_name: ::buffa::alloc::string::String, + /// Field 4: `outcome` + #[serde(rename = "outcome", with = "::buffa::json_helpers::proto_enum")] + pub outcome: ::buffa::EnumValue, + /// True when the call started and no terminal outcome was ever recorded. This + /// is the reader-visible form of an interrupted call awaiting reconciliation. + /// + /// Field 5: `unreconciled` + #[serde(rename = "unreconciled", with = "::buffa::json_helpers::proto_bool")] + pub unreconciled: bool, +} +impl ::core::fmt::Debug for ToolCallItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ToolCallItem") + .field("turn_id", &self.turn_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_name", &self.tool_name) + .field("outcome", &self.outcome) + .field("unreconciled", &self.unreconciled) + .finish() + } +} +impl ToolCallItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ToolCallItem"; +} +::buffa::impl_default_instance!(ToolCallItem); +impl ::buffa::MessageName for ToolCallItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ToolCallItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ToolCallItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ToolCallItem"; +} +impl ::buffa::Message for ToolCallItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_name, buf); + ::buffa::types::put_int32_field(4u32, self.outcome.to_i32(), buf); + ::buffa::types::put_bool_field(5u32, self.unreconciled, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_name, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.unreconciled = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.turn_id.clear(); + self.tool_call_id.clear(); + self.tool_name.clear(); + self.outcome = ::buffa::EnumValue::from(0); + self.unreconciled = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ToolCallItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __TOOL_CALL_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ToolCallItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// FileChangeItem is one workspace file change attributed to a tool call. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct FileChangeItem { + /// Field 1: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 3: `path` + #[serde(rename = "path", with = "::buffa::json_helpers::proto_string")] + pub path: ::buffa::alloc::string::String, + /// Field 4: `change_kind` + #[serde( + rename = "changeKind", + alias = "change_kind", + with = "::buffa::json_helpers::proto_enum" + )] + pub change_kind: ::buffa::EnumValue, + /// Set only for a rename. + /// + /// Field 5: `previous_path` + #[serde( + rename = "previousPath", + alias = "previous_path", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub previous_path: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for FileChangeItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FileChangeItem") + .field("turn_id", &self.turn_id) + .field("tool_call_id", &self.tool_call_id) + .field("path", &self.path) + .field("change_kind", &self.change_kind) + .field("previous_path", &self.previous_path) + .finish() + } +} +impl FileChangeItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.FileChangeItem"; +} +impl FileChangeItem { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::previous_path`] to `Some(value)`, consuming and returning `self`. + pub fn with_previous_path( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.previous_path = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(FileChangeItem); +impl ::buffa::MessageName for FileChangeItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "FileChangeItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.FileChangeItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.FileChangeItem"; +} +impl ::buffa::Message for FileChangeItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + { + let val = self.change_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.previous_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.turn_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.path, buf); + ::buffa::types::put_int32_field(4u32, self.change_kind.to_i32(), buf); + if let Some(ref v) = self.previous_path { + ::buffa::types::put_string_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.path, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.change_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .previous_path + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.turn_id.clear(); + self.tool_call_id.clear(); + self.path.clear(); + self.change_kind = ::buffa::EnumValue::from(0); + self.previous_path = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for FileChangeItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FILE_CHANGE_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.FileChangeItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SystemNoticeItem is a system-originated notice surfaced in the transcript. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SystemNoticeItem { + /// Field 1: `level` + #[serde(rename = "level", with = "::buffa::json_helpers::proto_enum")] + pub level: ::buffa::EnumValue, + /// Field 2: `text` + #[serde(rename = "text", with = "::buffa::json_helpers::proto_string")] + pub text: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for SystemNoticeItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SystemNoticeItem") + .field("level", &self.level) + .field("text", &self.text) + .finish() + } +} +impl SystemNoticeItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem"; +} +::buffa::impl_default_instance!(SystemNoticeItem); +impl ::buffa::MessageName for SystemNoticeItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SystemNoticeItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem"; +} +impl ::buffa::Message for SystemNoticeItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.level.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.level.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.text, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.level = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.text, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.level = ::buffa::EnumValue::from(0); + self.text.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SystemNoticeItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SYSTEM_NOTICE_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SystemNoticeItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// CompactionItem marks where a range of history was replaced by a summary. +/// +/// It is surfaced rather than hidden so a reader can see that the transcript it +/// is looking at is not the whole transcript. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CompactionItem { + /// Inclusive ordinal range this summary stands in for. + /// + /// Field 1: `covers_from` + #[serde( + rename = "coversFrom", + alias = "covers_from", + with = "::buffa::json_helpers::uint64" + )] + pub covers_from: u64, + /// Field 2: `covers_through` + #[serde( + rename = "coversThrough", + alias = "covers_through", + with = "::buffa::json_helpers::uint64" + )] + pub covers_through: u64, + /// Field 3: `summary_text` + #[serde( + rename = "summaryText", + alias = "summary_text", + with = "::buffa::json_helpers::proto_string" + )] + pub summary_text: ::buffa::alloc::string::String, + /// Field 4: `truncated` + #[serde(rename = "truncated", with = "::buffa::json_helpers::proto_bool")] + pub truncated: bool, +} +impl ::core::fmt::Debug for CompactionItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CompactionItem") + .field("covers_from", &self.covers_from) + .field("covers_through", &self.covers_through) + .field("summary_text", &self.summary_text) + .field("truncated", &self.truncated) + .finish() + } +} +impl CompactionItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CompactionItem"; +} +::buffa::impl_default_instance!(CompactionItem); +impl ::buffa::MessageName for CompactionItem { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CompactionItem"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CompactionItem"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CompactionItem"; +} +impl ::buffa::Message for CompactionItem { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.covers_from) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.covers_through) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_text) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.covers_from, buf); + ::buffa::types::put_uint64_field(2u32, self.covers_through, buf); + ::buffa::types::put_string_field(3u32, &self.summary_text, buf); + ::buffa::types::put_bool_field(4u32, self.truncated, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.covers_from = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.covers_through = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.summary_text, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.truncated = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.covers_from = 0u64; + self.covers_through = 0u64; + self.summary_text.clear(); + self.truncated = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CompactionItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMPACTION_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CompactionItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.__view.rs new file mode 100644 index 0000000000..de18b17deb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.__view.rs @@ -0,0 +1,1483 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/latest_session.proto + +/// GetLatestSessionRequest asks for the one newest session matching a selector. +/// +/// A resume command wants a single session, and getting it by listing a page and +/// taking the first row is wrong in a way that only shows up under load: the +/// list is ordered by recency but filtered afterwards, so a workspace whose most +/// recent forty sessions are all ineligible returns a page with no answer in it +/// and no indication that a longer page would have found one. Selection has to +/// happen in the index, not in the caller. +/// +/// This is also the query where staleness costs the most. A stale list is a list +/// with an old row in it, which a human reading a picker can notice. A stale +/// latest-pointer is the one answer the caller acts on, so the whole error lands +/// on the session that gets opened. +#[derive(Clone, Debug, Default)] +pub struct GetLatestSessionRequestView<'a> { + /// Field 1: `workspace_id` + pub workspace_id: &'a str, + /// Field 2: `accepted_contract` + pub accepted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Which session counts as the answer. + /// + /// Field 3: `selector` + pub selector: ::buffa::EnumValue, + /// Which timestamp "latest" is measured by. + /// + /// Field 4: `recency` + pub recency: ::buffa::EnumValue, + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 5: `consistency` + pub consistency: ::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> GetLatestSessionRequestView<'a> { + /**Whether required field `workspace_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `accepted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_accepted_contract(&self) -> bool { + self.accepted_contract.is_set() + } + /**Whether required field `selector` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_selector(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `recency` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_recency(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for GetLatestSessionRequestView<'a> { + type Owned = super::super::GetLatestSessionRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.workspace_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.accepted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.accepted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.selector = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.recency = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.consistency.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.consistency = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetLatestSessionRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetLatestSessionRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetLatestSessionRequest { + workspace_id: self.workspace_id.to_string(), + accepted_contract: match self.accepted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + selector: self.selector, + recency: self.recency, + consistency: match self.consistency.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReadConsistency, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetLatestSessionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.workspace_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.selector.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.recency.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.workspace_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.selector.to_i32(), buf); + ::buffa::types::put_int32_field(4u32, self.recency.to_i32(), buf); + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetLatestSessionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("workspaceId", self.workspace_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.accepted_contract.as_option() + { + __map.serialize_entry("acceptedContract", __v)?; + } + } + { + __map.serialize_entry("selector", &self.selector)?; + } + { + __map.serialize_entry("recency", &self.recency)?; + } + { + if let ::core::option::Option::Some(__v) = self.consistency.as_option() { + __map.serialize_entry("consistency", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetLatestSessionRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetLatestSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest"; +} +::buffa::impl_default_view_instance!(GetLatestSessionRequestView); +::buffa::impl_view_reborrow!(GetLatestSessionRequestView); +/** Self-contained, `'static` owned view of a `GetLatestSessionRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetLatestSessionRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetLatestSessionRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetLatestSessionRequestOwnedView( + ::buffa::OwnedView>, +); +impl GetLatestSessionRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetLatestSessionRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetLatestSessionRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetLatestSessionRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetLatestSessionRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `workspace_id` + #[must_use] + pub fn workspace_id(&self) -> &'_ str { + self.0.reborrow().workspace_id + } + /// Field 2: `accepted_contract` + #[must_use] + pub fn accepted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().accepted_contract + } + /// Which session counts as the answer. + /// + /// Field 3: `selector` + #[must_use] + pub fn selector(&self) -> ::buffa::EnumValue { + self.0.reborrow().selector + } + /// Which timestamp "latest" is measured by. + /// + /// Field 4: `recency` + #[must_use] + pub fn recency(&self) -> ::buffa::EnumValue { + self.0.reborrow().recency + } + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 5: `consistency` + #[must_use] + pub fn consistency( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'_>, + > { + &self.0.reborrow().consistency + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetLatestSessionRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetLatestSessionRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetLatestSessionRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetLatestSessionRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetLatestSessionRequest { + type View<'a> = GetLatestSessionRequestView<'a>; + type ViewHandle = GetLatestSessionRequestOwnedView; +} +impl ::serde::Serialize for GetLatestSessionRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// GetLatestSessionResponse is the single newest matching session, or nothing. +#[derive(Clone, Debug, Default)] +pub struct GetLatestSessionResponseView<'a> { + /// Field 1: `contract` + pub contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'a>, + >, + /// Unset when nothing in the workspace matched. Absence is the answer, not an + /// error: a workspace with no resumable session is a normal state, and + /// reporting it as a failure would make a first-run workspace look broken. + /// + /// Field 2: `session` + pub session: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionSummaryView<'a>, + >, + /// What the selector rejected on the way to that answer. Always present, + /// including when a session was found. + /// + /// This is what makes an empty answer diagnosable. "No resumable session" and + /// "eleven sessions, all still running" are the same absence to a caller that + /// only sees the empty field, and they call for opposite next moves: create a + /// new session, or attach to a running one. + /// + /// Field 3: `excluded` + pub excluded: ::buffa::MessageFieldView< + super::super::__buffa::view::ExclusionCountsView<'a>, + >, + /// Field 4: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, +} +impl<'a> GetLatestSessionResponseView<'a> { + /**Whether required field `contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract(&self) -> bool { + self.contract.is_set() + } + /**Whether required field `excluded` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_excluded(&self) -> bool { + self.excluded.is_set() + } + /**Whether required field `freshness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_freshness(&self) -> bool { + self.freshness.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for GetLatestSessionResponseView<'a> { + type Owned = super::super::GetLatestSessionResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.session.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.session = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.excluded.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.excluded = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::GetLatestSessionResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::GetLatestSessionResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::GetLatestSessionResponse { + contract: match self.contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractNegotiation, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + session: match self.session.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionSummary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + excluded: match self.excluded.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ExclusionCounts, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for GetLatestSessionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.session.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.excluded.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.excluded.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + if self.session.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session.write_to(__cache, buf); + } + if self.excluded.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.excluded.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for GetLatestSessionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.contract.as_option() { + __map.serialize_entry("contract", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.session.as_option() { + __map.serialize_entry("session", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.excluded.as_option() { + __map.serialize_entry("excluded", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for GetLatestSessionResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetLatestSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse"; +} +::buffa::impl_default_view_instance!(GetLatestSessionResponseView); +::buffa::impl_view_reborrow!(GetLatestSessionResponseView); +/** Self-contained, `'static` owned view of a `GetLatestSessionResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`GetLatestSessionResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`GetLatestSessionResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct GetLatestSessionResponseOwnedView( + ::buffa::OwnedView>, +); +impl GetLatestSessionResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::GetLatestSessionResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + GetLatestSessionResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`GetLatestSessionResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &GetLatestSessionResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::GetLatestSessionResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `contract` + #[must_use] + pub fn contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'_>, + > { + &self.0.reborrow().contract + } + /// Unset when nothing in the workspace matched. Absence is the answer, not an + /// error: a workspace with no resumable session is a normal state, and + /// reporting it as a failure would make a first-run workspace look broken. + /// + /// Field 2: `session` + #[must_use] + pub fn session( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionSummaryView<'_>, + > { + &self.0.reborrow().session + } + /// What the selector rejected on the way to that answer. Always present, + /// including when a session was found. + /// + /// This is what makes an empty answer diagnosable. "No resumable session" and + /// "eleven sessions, all still running" are the same absence to a caller that + /// only sees the empty field, and they call for opposite next moves: create a + /// new session, or attach to a running one. + /// + /// Field 3: `excluded` + #[must_use] + pub fn excluded( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ExclusionCountsView<'_>, + > { + &self.0.reborrow().excluded + } + /// Field 4: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for GetLatestSessionResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + GetLatestSessionResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: GetLatestSessionResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for GetLatestSessionResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::GetLatestSessionResponse { + type View<'a> = GetLatestSessionResponseView<'a>; + type ViewHandle = GetLatestSessionResponseOwnedView; +} +impl ::serde::Serialize for GetLatestSessionResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ExclusionCounts is how many candidate sessions each rule removed. +/// +/// A session removed by more than one rule is counted once, under the first rule +/// that removed it, in the order the fields are declared. Counting it under +/// every matching rule would produce totals that exceed the workspace, and the +/// number a caller wants is how many sessions there were, not how many +/// judgements were made. +#[derive(Clone, Debug, Default)] +pub struct ExclusionCountsView<'a> { + /// Sessions in the workspace the caller may see. The denominator; zero here + /// means an empty workspace rather than an over-strict selector. + /// + /// Field 1: `considered` + pub considered: u32, + /// Field 2: `archived` + pub archived: u32, + /// Excluded because something is currently driving them. + /// + /// Field 3: `active` + pub active: u32, + /// Excluded because their effective history contains no user-authored turn. + /// + /// Emptiness is defined on authored content, not on `effective_length`. A + /// session can carry configuration and lifecycle records and still be one + /// nobody ever said anything in, and a rewind back to the start empties a + /// session that was not empty an hour ago. Resuming one of those puts a person + /// back into a blank window they have no memory of leaving. + /// + /// Field 4: `empty` + pub empty: u32, + /// Excluded by TERMINAL_REASON_HIDDEN. + /// + /// Field 5: `hidden` + pub hidden: u32, + /// Excluded because the projection could not render the row. Non-zero means + /// the answer may be wrong rather than merely empty: the session that should + /// have won might be one of these. + /// + /// Field 6: `unrenderable` + pub unrenderable: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> ExclusionCountsView<'a> { + /**Whether required field `considered` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_considered(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `archived` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_archived(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `active` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_active(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `empty` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_empty(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `hidden` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_hidden(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `unrenderable` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_unrenderable(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ExclusionCountsView<'a> { + type Owned = super::super::ExclusionCounts; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.considered = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.archived = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.active = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.empty = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.hidden = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.unrenderable = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ExclusionCounts { + considered: self.considered, + archived: self.archived, + active: self.active, + empty: self.empty, + hidden: self.hidden, + unrenderable: self.unrenderable, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ExclusionCountsView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.considered) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.archived) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.active) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.empty) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.hidden) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unrenderable) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.considered, buf); + ::buffa::types::put_uint32_field(2u32, self.archived, buf); + ::buffa::types::put_uint32_field(3u32, self.active, buf); + ::buffa::types::put_uint32_field(4u32, self.empty, buf); + ::buffa::types::put_uint32_field(5u32, self.hidden, buf); + ::buffa::types::put_uint32_field(6u32, self.unrenderable, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ExclusionCountsView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "considered", + &::buffa::json_helpers::ProtoJson(&self.considered), + )?; + } + { + __map + .serialize_entry( + "archived", + &::buffa::json_helpers::ProtoJson(&self.archived), + )?; + } + { + __map + .serialize_entry( + "active", + &::buffa::json_helpers::ProtoJson(&self.active), + )?; + } + { + __map + .serialize_entry( + "empty", + &::buffa::json_helpers::ProtoJson(&self.empty), + )?; + } + { + __map + .serialize_entry( + "hidden", + &::buffa::json_helpers::ProtoJson(&self.hidden), + )?; + } + { + __map + .serialize_entry( + "unrenderable", + &::buffa::json_helpers::ProtoJson(&self.unrenderable), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ExclusionCountsView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ExclusionCounts"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ExclusionCounts"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ExclusionCounts"; +} +::buffa::impl_default_view_instance!(ExclusionCountsView); +::buffa::impl_view_reborrow!(ExclusionCountsView); +/** Self-contained, `'static` owned view of a `ExclusionCounts` message. + + Wraps [`::buffa::OwnedView`]`<`[`ExclusionCountsView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ExclusionCountsView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ExclusionCountsOwnedView(::buffa::OwnedView>); +impl ExclusionCountsOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExclusionCountsOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExclusionCountsOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ExclusionCounts, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExclusionCountsOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ExclusionCountsView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ExclusionCountsView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ExclusionCounts { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Sessions in the workspace the caller may see. The denominator; zero here + /// means an empty workspace rather than an over-strict selector. + /// + /// Field 1: `considered` + #[must_use] + pub fn considered(&self) -> u32 { + self.0.reborrow().considered + } + /// Field 2: `archived` + #[must_use] + pub fn archived(&self) -> u32 { + self.0.reborrow().archived + } + /// Excluded because something is currently driving them. + /// + /// Field 3: `active` + #[must_use] + pub fn active(&self) -> u32 { + self.0.reborrow().active + } + /// Excluded because their effective history contains no user-authored turn. + /// + /// Emptiness is defined on authored content, not on `effective_length`. A + /// session can carry configuration and lifecycle records and still be one + /// nobody ever said anything in, and a rewind back to the start empties a + /// session that was not empty an hour ago. Resuming one of those puts a person + /// back into a blank window they have no memory of leaving. + /// + /// Field 4: `empty` + #[must_use] + pub fn empty(&self) -> u32 { + self.0.reborrow().empty + } + /// Excluded by TERMINAL_REASON_HIDDEN. + /// + /// Field 5: `hidden` + #[must_use] + pub fn hidden(&self) -> u32 { + self.0.reborrow().hidden + } + /// Excluded because the projection could not render the row. Non-zero means + /// the answer may be wrong rather than merely empty: the session that should + /// have won might be one of these. + /// + /// Field 6: `unrenderable` + #[must_use] + pub fn unrenderable(&self) -> u32 { + self.0.reborrow().unrenderable + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ExclusionCountsOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ExclusionCountsOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ExclusionCountsOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ExclusionCountsOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ExclusionCounts { + type View<'a> = ExclusionCountsView<'a>; + type ViewHandle = ExclusionCountsOwnedView; +} +impl ::serde::Serialize for ExclusionCountsOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.rs new file mode 100644 index 0000000000..aab2d44c05 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.latest_session.rs @@ -0,0 +1,1023 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/latest_session.proto + +/// SessionSelector is which session in a workspace counts as the answer. +/// +/// An enum rather than a set of filter booleans. Booleans let a caller ask for a +/// session that is both currently active and not currently active, and the +/// server then has to decide what an impossible request means. Every value here +/// is a question someone actually asks. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SessionSelector { + /// No selector given. Refused with QUERY_ERROR_CODE_INVALID_ARGUMENT. + /// + /// The zero value does not default to a selector, because the two callers of + /// this query want different ones and both are plausible defaults: a picker + /// wants the most recent session of any kind, and a resume wants a resumable + /// one. Guessing wrong hands a resume command a session that is already + /// running somewhere else. + SESSION_SELECTOR_UNSPECIFIED = 0i32, + /// The newest non-archived session, whatever state it is in. + SESSION_SELECTOR_MOST_RECENT = 1i32, + /// The newest session a resume can attach to: not archived, not currently + /// active, not empty, and not hidden. + /// + /// Terminal is not an exclusion. A closed session is the ordinary thing to + /// resume; that is what resuming means. What is excluded is a session already + /// being driven from somewhere else, which resuming would turn into two + /// writers on one stream. + SESSION_SELECTOR_RESUMABLE = 2i32, + /// The newest session currently being driven. Answers "reattach me to what I + /// was doing" without a resume's exclusions. + SESSION_SELECTOR_ACTIVE = 3i32, +} +impl SessionSelector { + ///Idiomatic alias for [`Self::SESSION_SELECTOR_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SESSION_SELECTOR_UNSPECIFIED; + ///Idiomatic alias for [`Self::SESSION_SELECTOR_MOST_RECENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MostRecent: Self = Self::SESSION_SELECTOR_MOST_RECENT; + ///Idiomatic alias for [`Self::SESSION_SELECTOR_RESUMABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Resumable: Self = Self::SESSION_SELECTOR_RESUMABLE; + ///Idiomatic alias for [`Self::SESSION_SELECTOR_ACTIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Active: Self = Self::SESSION_SELECTOR_ACTIVE; +} +impl ::core::default::Default for SessionSelector { + fn default() -> Self { + Self::SESSION_SELECTOR_UNSPECIFIED + } +} +impl ::serde::Serialize for SessionSelector { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SessionSelector { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SessionSelector; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(SessionSelector) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionSelector { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SessionSelector { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SESSION_SELECTOR_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SESSION_SELECTOR_MOST_RECENT), + 2i32 => ::core::option::Option::Some(Self::SESSION_SELECTOR_RESUMABLE), + 3i32 => ::core::option::Option::Some(Self::SESSION_SELECTOR_ACTIVE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SESSION_SELECTOR_UNSPECIFIED => "SESSION_SELECTOR_UNSPECIFIED", + Self::SESSION_SELECTOR_MOST_RECENT => "SESSION_SELECTOR_MOST_RECENT", + Self::SESSION_SELECTOR_RESUMABLE => "SESSION_SELECTOR_RESUMABLE", + Self::SESSION_SELECTOR_ACTIVE => "SESSION_SELECTOR_ACTIVE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SESSION_SELECTOR_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SESSION_SELECTOR_UNSPECIFIED) + } + "SESSION_SELECTOR_MOST_RECENT" => { + ::core::option::Option::Some(Self::SESSION_SELECTOR_MOST_RECENT) + } + "SESSION_SELECTOR_RESUMABLE" => { + ::core::option::Option::Some(Self::SESSION_SELECTOR_RESUMABLE) + } + "SESSION_SELECTOR_ACTIVE" => { + ::core::option::Option::Some(Self::SESSION_SELECTOR_ACTIVE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SESSION_SELECTOR_UNSPECIFIED, + Self::SESSION_SELECTOR_MOST_RECENT, + Self::SESSION_SELECTOR_RESUMABLE, + Self::SESSION_SELECTOR_ACTIVE, + ] + } +} +/// RecencyBasis is which timestamp "latest" is measured by. +/// +/// The two orderings disagree often enough to matter: a long session started +/// yesterday and worked on this morning is the newest by activity and among the +/// oldest by creation. Every timestamp behind this is a recorded external +/// occurrence and not the moment an envelope was appended (D10), so a projection +/// that catches up late does not reorder the answer. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RecencyBasis { + /// Unset. Treated as LAST_ACTIVITY, which is what a resume means by "latest". + RECENCY_BASIS_UNSPECIFIED = 0i32, + /// Most recent effective history activity. + RECENCY_BASIS_LAST_ACTIVITY = 1i32, + /// Session creation. + RECENCY_BASIS_CREATED = 2i32, +} +impl RecencyBasis { + ///Idiomatic alias for [`Self::RECENCY_BASIS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RECENCY_BASIS_UNSPECIFIED; + ///Idiomatic alias for [`Self::RECENCY_BASIS_LAST_ACTIVITY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const LastActivity: Self = Self::RECENCY_BASIS_LAST_ACTIVITY; + ///Idiomatic alias for [`Self::RECENCY_BASIS_CREATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Created: Self = Self::RECENCY_BASIS_CREATED; +} +impl ::core::default::Default for RecencyBasis { + fn default() -> Self { + Self::RECENCY_BASIS_UNSPECIFIED + } +} +impl ::serde::Serialize for RecencyBasis { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RecencyBasis { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RecencyBasis; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(RecencyBasis)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecencyBasis { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RecencyBasis { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::RECENCY_BASIS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::RECENCY_BASIS_LAST_ACTIVITY), + 2i32 => ::core::option::Option::Some(Self::RECENCY_BASIS_CREATED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RECENCY_BASIS_UNSPECIFIED => "RECENCY_BASIS_UNSPECIFIED", + Self::RECENCY_BASIS_LAST_ACTIVITY => "RECENCY_BASIS_LAST_ACTIVITY", + Self::RECENCY_BASIS_CREATED => "RECENCY_BASIS_CREATED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RECENCY_BASIS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RECENCY_BASIS_UNSPECIFIED) + } + "RECENCY_BASIS_LAST_ACTIVITY" => { + ::core::option::Option::Some(Self::RECENCY_BASIS_LAST_ACTIVITY) + } + "RECENCY_BASIS_CREATED" => { + ::core::option::Option::Some(Self::RECENCY_BASIS_CREATED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RECENCY_BASIS_UNSPECIFIED, + Self::RECENCY_BASIS_LAST_ACTIVITY, + Self::RECENCY_BASIS_CREATED, + ] + } +} +/// GetLatestSessionRequest asks for the one newest session matching a selector. +/// +/// A resume command wants a single session, and getting it by listing a page and +/// taking the first row is wrong in a way that only shows up under load: the +/// list is ordered by recency but filtered afterwards, so a workspace whose most +/// recent forty sessions are all ineligible returns a page with no answer in it +/// and no indication that a longer page would have found one. Selection has to +/// happen in the index, not in the caller. +/// +/// This is also the query where staleness costs the most. A stale list is a list +/// with an old row in it, which a human reading a picker can notice. A stale +/// latest-pointer is the one answer the caller acts on, so the whole error lands +/// on the session that gets opened. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetLatestSessionRequest { + /// Field 1: `workspace_id` + #[serde( + rename = "workspaceId", + alias = "workspace_id", + with = "::buffa::json_helpers::proto_string" + )] + pub workspace_id: ::buffa::alloc::string::String, + /// Field 2: `accepted_contract` + #[serde(rename = "acceptedContract", alias = "accepted_contract")] + pub accepted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Which session counts as the answer. + /// + /// Field 3: `selector` + #[serde(rename = "selector", with = "::buffa::json_helpers::proto_enum")] + pub selector: ::buffa::EnumValue, + /// Which timestamp "latest" is measured by. + /// + /// Field 4: `recency` + #[serde(rename = "recency", with = "::buffa::json_helpers::proto_enum")] + pub recency: ::buffa::EnumValue, + /// Freshness the caller requires. Unset is an eventual read. + /// + /// Field 5: `consistency` + #[serde( + rename = "consistency", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub consistency: ::buffa::MessageField< + ReadConsistency, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetLatestSessionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetLatestSessionRequest") + .field("workspace_id", &self.workspace_id) + .field("accepted_contract", &self.accepted_contract) + .field("selector", &self.selector) + .field("recency", &self.recency) + .field("consistency", &self.consistency) + .finish() + } +} +impl GetLatestSessionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest"; +} +::buffa::impl_default_instance!(GetLatestSessionRequest); +impl ::buffa::MessageName for GetLatestSessionRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetLatestSessionRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest"; +} +impl ::buffa::Message for GetLatestSessionRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.workspace_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.selector.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.recency.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.workspace_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.selector.to_i32(), buf); + ::buffa::types::put_int32_field(4u32, self.recency.to_i32(), buf); + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.workspace_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.accepted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.selector = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.recency = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.consistency.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.workspace_id.clear(); + self.accepted_contract = ::buffa::MessageField::none(); + self.selector = ::buffa::EnumValue::from(0); + self.recency = ::buffa::EnumValue::from(0); + self.consistency = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetLatestSessionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_LATEST_SESSION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// GetLatestSessionResponse is the single newest matching session, or nothing. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetLatestSessionResponse { + /// Field 1: `contract` + #[serde(rename = "contract")] + pub contract: ::buffa::MessageField< + ContractNegotiation, + ::buffa::Inline, + >, + /// Unset when nothing in the workspace matched. Absence is the answer, not an + /// error: a workspace with no resumable session is a normal state, and + /// reporting it as a failure would make a first-run workspace look broken. + /// + /// Field 2: `session` + #[serde( + rename = "session", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub session: ::buffa::MessageField>, + /// What the selector rejected on the way to that answer. Always present, + /// including when a session was found. + /// + /// This is what makes an empty answer diagnosable. "No resumable session" and + /// "eleven sessions, all still running" are the same absence to a caller that + /// only sees the empty field, and they call for opposite next moves: create a + /// new session, or attach to a running one. + /// + /// Field 3: `excluded` + #[serde(rename = "excluded")] + pub excluded: ::buffa::MessageField< + ExclusionCounts, + ::buffa::Inline, + >, + /// Field 4: `freshness` + #[serde(rename = "freshness")] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for GetLatestSessionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetLatestSessionResponse") + .field("contract", &self.contract) + .field("session", &self.session) + .field("excluded", &self.excluded) + .field("freshness", &self.freshness) + .finish() + } +} +impl GetLatestSessionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse"; +} +::buffa::impl_default_instance!(GetLatestSessionResponse); +impl ::buffa::MessageName for GetLatestSessionResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "GetLatestSessionResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse"; +} +impl ::buffa::Message for GetLatestSessionResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.session.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.excluded.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.excluded.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + if self.session.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session.write_to(__cache, buf); + } + if self.excluded.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.excluded.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.session.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.excluded.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.contract = ::buffa::MessageField::none(); + self.session = ::buffa::MessageField::none(); + self.excluded = ::buffa::MessageField::none(); + self.freshness = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetLatestSessionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_LATEST_SESSION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.GetLatestSessionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ExclusionCounts is how many candidate sessions each rule removed. +/// +/// A session removed by more than one rule is counted once, under the first rule +/// that removed it, in the order the fields are declared. Counting it under +/// every matching rule would produce totals that exceed the workspace, and the +/// number a caller wants is how many sessions there were, not how many +/// judgements were made. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ExclusionCounts { + /// Sessions in the workspace the caller may see. The denominator; zero here + /// means an empty workspace rather than an over-strict selector. + /// + /// Field 1: `considered` + #[serde(rename = "considered", with = "::buffa::json_helpers::uint32")] + pub considered: u32, + /// Field 2: `archived` + #[serde(rename = "archived", with = "::buffa::json_helpers::uint32")] + pub archived: u32, + /// Excluded because something is currently driving them. + /// + /// Field 3: `active` + #[serde(rename = "active", with = "::buffa::json_helpers::uint32")] + pub active: u32, + /// Excluded because their effective history contains no user-authored turn. + /// + /// Emptiness is defined on authored content, not on `effective_length`. A + /// session can carry configuration and lifecycle records and still be one + /// nobody ever said anything in, and a rewind back to the start empties a + /// session that was not empty an hour ago. Resuming one of those puts a person + /// back into a blank window they have no memory of leaving. + /// + /// Field 4: `empty` + #[serde(rename = "empty", with = "::buffa::json_helpers::uint32")] + pub empty: u32, + /// Excluded by TERMINAL_REASON_HIDDEN. + /// + /// Field 5: `hidden` + #[serde(rename = "hidden", with = "::buffa::json_helpers::uint32")] + pub hidden: u32, + /// Excluded because the projection could not render the row. Non-zero means + /// the answer may be wrong rather than merely empty: the session that should + /// have won might be one of these. + /// + /// Field 6: `unrenderable` + #[serde(rename = "unrenderable", with = "::buffa::json_helpers::uint32")] + pub unrenderable: u32, +} +impl ::core::fmt::Debug for ExclusionCounts { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ExclusionCounts") + .field("considered", &self.considered) + .field("archived", &self.archived) + .field("active", &self.active) + .field("empty", &self.empty) + .field("hidden", &self.hidden) + .field("unrenderable", &self.unrenderable) + .finish() + } +} +impl ExclusionCounts { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ExclusionCounts"; +} +::buffa::impl_default_instance!(ExclusionCounts); +impl ::buffa::MessageName for ExclusionCounts { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ExclusionCounts"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ExclusionCounts"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ExclusionCounts"; +} +impl ::buffa::Message for ExclusionCounts { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.considered) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.archived) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.active) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.empty) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.hidden) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unrenderable) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.considered, buf); + ::buffa::types::put_uint32_field(2u32, self.archived, buf); + ::buffa::types::put_uint32_field(3u32, self.active, buf); + ::buffa::types::put_uint32_field(4u32, self.empty, buf); + ::buffa::types::put_uint32_field(5u32, self.hidden, buf); + ::buffa::types::put_uint32_field(6u32, self.unrenderable, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.considered = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.archived = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.active = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.empty = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.hidden = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.unrenderable = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.considered = 0u32; + self.archived = 0u32; + self.active = 0u32; + self.empty = 0u32; + self.hidden = 0u32; + self.unrenderable = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ExclusionCounts { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __EXCLUSION_COUNTS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ExclusionCounts", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.__view.rs new file mode 100644 index 0000000000..351807bd8a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.__view.rs @@ -0,0 +1,1128 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/list_sessions.proto + +/// ListSessionsRequest enumerates sessions in a scope, newest first. +#[derive(Clone, Debug, Default)] +pub struct ListSessionsRequestView<'a> { + /// Field 1: `accepted_contract` + pub accepted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Field 2: `scope` + pub scope: ::buffa::EnumValue, + /// Required for SCOPE_WORKSPACE, ignored otherwise. + /// + /// Field 3: `workspace_id` + pub workspace_id: ::core::option::Option<&'a str>, + /// Field 4: `archived` + pub archived: ::buffa::EnumValue, + /// Maximum rows to return. The server may return fewer. A value above the + /// configured admission limit is refused with + /// QUERY_ERROR_CODE_RESOURCE_EXHAUSTED rather than silently clamped, so a + /// caller is never left believing it asked for more than it received. + /// + /// Field 5: `page_size` + pub page_size: u32, + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. The caller must treat this as bytes and never + /// construct, parse, or edit one. + /// + /// A continuation still carries the scope, workspace, and archived filter, and + /// they must match what the cursor was minted with. The server refuses a + /// disagreement rather than re-scoping the scan in flight. + /// + /// Field 6: `page_token` + pub page_token: ::core::option::Option<&'a [u8]>, + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, because a continuation is served from the pinned watermark + /// and waiting for anything newer could not change what it returns. + /// + /// A continuation whose requirement is stricter than the one the scan was + /// opened with is QUERY_ERROR_CODE_INVALID_ARGUMENT. Silently ignoring it + /// would let a caller believe a later page reflects a write that it cannot. + /// + /// Field 7: `consistency` + pub consistency: ::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ListSessionsRequestView<'a> { + /**Whether required field `accepted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_accepted_contract(&self) -> bool { + self.accepted_contract.is_set() + } + /**Whether required field `scope` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_scope(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `archived` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_archived(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `page_size` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_page_size(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ListSessionsRequestView<'a> { + type Owned = super::super::ListSessionsRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.accepted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.accepted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.scope = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.workspace_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.archived = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.page_size = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.consistency.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.consistency = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ListSessionsRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ListSessionsRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ListSessionsRequest { + accepted_contract: match self.accepted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + scope: self.scope, + workspace_id: self.workspace_id.map(|s| s.to_string()), + archived: self.archived, + page_size: self.page_size, + page_token: self.page_token.map(|b| (b).to_vec()), + consistency: match self.consistency.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReadConsistency, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ListSessionsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.scope.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.archived.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.scope.to_i32(), buf); + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_int32_field(4u32, self.archived.to_i32(), buf); + ::buffa::types::put_uint32_field(5u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(6u32, v, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ListSessionsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.accepted_contract.as_option() + { + __map.serialize_entry("acceptedContract", __v)?; + } + } + { + __map.serialize_entry("scope", &self.scope)?; + } + if let ::core::option::Option::Some(__v) = self.workspace_id { + __map.serialize_entry("workspaceId", __v)?; + } + { + __map.serialize_entry("archived", &self.archived)?; + } + { + __map + .serialize_entry( + "pageSize", + &::buffa::json_helpers::ProtoJson(&self.page_size), + )?; + } + if let ::core::option::Option::Some(__v) = self.page_token { + __map.serialize_entry("pageToken", &::buffa::json_helpers::BytesJson(__v))?; + } + { + if let ::core::option::Option::Some(__v) = self.consistency.as_option() { + __map.serialize_entry("consistency", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ListSessionsRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListSessionsRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest"; +} +::buffa::impl_default_view_instance!(ListSessionsRequestView); +::buffa::impl_view_reborrow!(ListSessionsRequestView); +/** Self-contained, `'static` owned view of a `ListSessionsRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ListSessionsRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ListSessionsRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ListSessionsRequestOwnedView( + ::buffa::OwnedView>, +); +impl ListSessionsRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ListSessionsRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ListSessionsRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ListSessionsRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ListSessionsRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `accepted_contract` + #[must_use] + pub fn accepted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().accepted_contract + } + /// Field 2: `scope` + #[must_use] + pub fn scope(&self) -> ::buffa::EnumValue { + self.0.reborrow().scope + } + /// Required for SCOPE_WORKSPACE, ignored otherwise. + /// + /// Field 3: `workspace_id` + #[must_use] + pub fn workspace_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().workspace_id + } + /// Field 4: `archived` + #[must_use] + pub fn archived(&self) -> ::buffa::EnumValue { + self.0.reborrow().archived + } + /// Maximum rows to return. The server may return fewer. A value above the + /// configured admission limit is refused with + /// QUERY_ERROR_CODE_RESOURCE_EXHAUSTED rather than silently clamped, so a + /// caller is never left believing it asked for more than it received. + /// + /// Field 5: `page_size` + #[must_use] + pub fn page_size(&self) -> u32 { + self.0.reborrow().page_size + } + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. The caller must treat this as bytes and never + /// construct, parse, or edit one. + /// + /// A continuation still carries the scope, workspace, and archived filter, and + /// they must match what the cursor was minted with. The server refuses a + /// disagreement rather than re-scoping the scan in flight. + /// + /// Field 6: `page_token` + #[must_use] + pub fn page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().page_token + } + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, because a continuation is served from the pinned watermark + /// and waiting for anything newer could not change what it returns. + /// + /// A continuation whose requirement is stricter than the one the scan was + /// opened with is QUERY_ERROR_CODE_INVALID_ARGUMENT. Silently ignoring it + /// would let a caller believe a later page reflects a write that it cannot. + /// + /// Field 7: `consistency` + #[must_use] + pub fn consistency( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReadConsistencyView<'_>, + > { + &self.0.reborrow().consistency + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ListSessionsRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ListSessionsRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ListSessionsRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ListSessionsRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ListSessionsRequest { + type View<'a> = ListSessionsRequestView<'a>; + type ViewHandle = ListSessionsRequestOwnedView; +} +impl ::serde::Serialize for ListSessionsRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ListSessionsResponse is one page of session summaries. +#[derive(Clone, Debug, Default)] +pub struct ListSessionsResponseView<'a> { + /// Field 1: `contract` + pub contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'a>, + >, + /// Field 2: `sessions` + pub sessions: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::SessionSummaryView<'a>, + >, + /// Unset when this is the last page. Presence, not an empty `sessions` list, + /// is the end-of-scan signal: a page may legitimately be empty while more + /// pages remain. + /// + /// Field 3: `next_page_token` + pub next_page_token: ::core::option::Option<&'a [u8]>, + /// Rows the server could not decode or render and therefore skipped. A + /// non-zero count means this page is incomplete, and a caller must not read + /// the result as an exhaustive list. Reporting zero is not the same as not + /// reporting. + /// + /// Field 4: `skipped_count` + pub skipped_count: u32, + /// The projection position this scan is pinned to, equal on every page of one + /// scan. It is the scan anchor, not a freshness report. + /// + /// A scan enumerates the ordering as it stood here, so a session that entered + /// the scope afterwards is not in it and will not appear on a later page. A + /// caller that needs newer rows starts a new scan; it does not keep paging and + /// wait for them to show up. + /// + /// Field 5: `pinned_watermark` + pub pinned_watermark: u64, + /// How current the read model was when the scan opened. Equal on every page, + /// since a pinned scan does not become fresher as it is paged. + /// + /// Field 6: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ListSessionsResponseView<'a> { + /**Whether required field `contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract(&self) -> bool { + self.contract.is_set() + } + /**Whether required field `skipped_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_skipped_count(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `pinned_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_pinned_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `freshness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_freshness(&self) -> bool { + self.freshness.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ListSessionsResponseView<'a> { + type Owned = super::super::ListSessionsResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.next_page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.skipped_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.pinned_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::SessionSummaryView, + >(), + )?; + view.sessions + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ListSessionsResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ListSessionsResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ListSessionsResponse { + contract: match self.contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractNegotiation, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + sessions: self + .sessions + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + next_page_token: self.next_page_token.map(|b| (b).to_vec()), + skipped_count: self.skipped_count, + pinned_watermark: self.pinned_watermark, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ListSessionsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.sessions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.skipped_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.pinned_watermark) as u64; + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + for v in &self.sessions { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + ::buffa::types::put_uint32_field(4u32, self.skipped_count, buf); + ::buffa::types::put_uint64_field(5u32, self.pinned_watermark, buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ListSessionsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.contract.as_option() { + __map.serialize_entry("contract", __v)?; + } + } + if !self.sessions.is_empty() { + __map.serialize_entry("sessions", &*self.sessions)?; + } + if let ::core::option::Option::Some(__v) = self.next_page_token { + __map + .serialize_entry( + "nextPageToken", + &::buffa::json_helpers::BytesJson(__v), + )?; + } + { + __map + .serialize_entry( + "skippedCount", + &::buffa::json_helpers::ProtoJson(&self.skipped_count), + )?; + } + { + __map + .serialize_entry( + "pinnedWatermark", + &::buffa::json_helpers::ProtoJson(&self.pinned_watermark), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ListSessionsResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListSessionsResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse"; +} +::buffa::impl_default_view_instance!(ListSessionsResponseView); +::buffa::impl_view_reborrow!(ListSessionsResponseView); +/** Self-contained, `'static` owned view of a `ListSessionsResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`ListSessionsResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ListSessionsResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ListSessionsResponseOwnedView( + ::buffa::OwnedView>, +); +impl ListSessionsResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ListSessionsResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListSessionsResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ListSessionsResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ListSessionsResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ListSessionsResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `contract` + #[must_use] + pub fn contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'_>, + > { + &self.0.reborrow().contract + } + /// Field 2: `sessions` + #[must_use] + pub fn sessions( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::SessionSummaryView<'_>, + > { + &self.0.reborrow().sessions + } + /// Unset when this is the last page. Presence, not an empty `sessions` list, + /// is the end-of-scan signal: a page may legitimately be empty while more + /// pages remain. + /// + /// Field 3: `next_page_token` + #[must_use] + pub fn next_page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().next_page_token + } + /// Rows the server could not decode or render and therefore skipped. A + /// non-zero count means this page is incomplete, and a caller must not read + /// the result as an exhaustive list. Reporting zero is not the same as not + /// reporting. + /// + /// Field 4: `skipped_count` + #[must_use] + pub fn skipped_count(&self) -> u32 { + self.0.reborrow().skipped_count + } + /// The projection position this scan is pinned to, equal on every page of one + /// scan. It is the scan anchor, not a freshness report. + /// + /// A scan enumerates the ordering as it stood here, so a session that entered + /// the scope afterwards is not in it and will not appear on a later page. A + /// caller that needs newer rows starts a new scan; it does not keep paging and + /// wait for them to show up. + /// + /// Field 5: `pinned_watermark` + #[must_use] + pub fn pinned_watermark(&self) -> u64 { + self.0.reborrow().pinned_watermark + } + /// How current the read model was when the scan opened. Equal on every page, + /// since a pinned scan does not become fresher as it is paged. + /// + /// Field 6: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ListSessionsResponseOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ListSessionsResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ListSessionsResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ListSessionsResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ListSessionsResponse { + type View<'a> = ListSessionsResponseView<'a>; + type ViewHandle = ListSessionsResponseOwnedView; +} +impl ::serde::Serialize for ListSessionsResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.rs new file mode 100644 index 0000000000..6ec9f10ca6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.list_sessions.rs @@ -0,0 +1,933 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/list_sessions.proto + +/// ListSessionsScope is which sessions are in range. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ListSessionsScope { + LIST_SESSIONS_SCOPE_UNSPECIFIED = 0i32, + /// Sessions bound to one workspace. + LIST_SESSIONS_SCOPE_WORKSPACE = 1i32, + /// Every session the caller may see, across workspaces. + LIST_SESSIONS_SCOPE_ALL = 2i32, +} +impl ListSessionsScope { + ///Idiomatic alias for [`Self::LIST_SESSIONS_SCOPE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::LIST_SESSIONS_SCOPE_UNSPECIFIED; + ///Idiomatic alias for [`Self::LIST_SESSIONS_SCOPE_WORKSPACE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Workspace: Self = Self::LIST_SESSIONS_SCOPE_WORKSPACE; + ///Idiomatic alias for [`Self::LIST_SESSIONS_SCOPE_ALL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const All: Self = Self::LIST_SESSIONS_SCOPE_ALL; +} +impl ::core::default::Default for ListSessionsScope { + fn default() -> Self { + Self::LIST_SESSIONS_SCOPE_UNSPECIFIED + } +} +impl ::serde::Serialize for ListSessionsScope { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ListSessionsScope { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ListSessionsScope; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ListSessionsScope) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListSessionsScope { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ListSessionsScope { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_WORKSPACE), + 2i32 => ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_ALL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::LIST_SESSIONS_SCOPE_UNSPECIFIED => "LIST_SESSIONS_SCOPE_UNSPECIFIED", + Self::LIST_SESSIONS_SCOPE_WORKSPACE => "LIST_SESSIONS_SCOPE_WORKSPACE", + Self::LIST_SESSIONS_SCOPE_ALL => "LIST_SESSIONS_SCOPE_ALL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "LIST_SESSIONS_SCOPE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_UNSPECIFIED) + } + "LIST_SESSIONS_SCOPE_WORKSPACE" => { + ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_WORKSPACE) + } + "LIST_SESSIONS_SCOPE_ALL" => { + ::core::option::Option::Some(Self::LIST_SESSIONS_SCOPE_ALL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::LIST_SESSIONS_SCOPE_UNSPECIFIED, + Self::LIST_SESSIONS_SCOPE_WORKSPACE, + Self::LIST_SESSIONS_SCOPE_ALL, + ] + } +} +/// ArchivedFilter is how archived sessions are treated. +/// +/// A tri-state rather than a boolean, because "exclude archived" and "archived +/// only" are both real views and a boolean can only express one of them +/// alongside the default. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ArchivedFilter { + ARCHIVED_FILTER_UNSPECIFIED = 0i32, + ARCHIVED_FILTER_EXCLUDE = 1i32, + ARCHIVED_FILTER_INCLUDE = 2i32, + ARCHIVED_FILTER_ONLY = 3i32, +} +impl ArchivedFilter { + ///Idiomatic alias for [`Self::ARCHIVED_FILTER_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ARCHIVED_FILTER_UNSPECIFIED; + ///Idiomatic alias for [`Self::ARCHIVED_FILTER_EXCLUDE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Exclude: Self = Self::ARCHIVED_FILTER_EXCLUDE; + ///Idiomatic alias for [`Self::ARCHIVED_FILTER_INCLUDE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Include: Self = Self::ARCHIVED_FILTER_INCLUDE; + ///Idiomatic alias for [`Self::ARCHIVED_FILTER_ONLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Only: Self = Self::ARCHIVED_FILTER_ONLY; +} +impl ::core::default::Default for ArchivedFilter { + fn default() -> Self { + Self::ARCHIVED_FILTER_UNSPECIFIED + } +} +impl ::serde::Serialize for ArchivedFilter { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ArchivedFilter { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ArchivedFilter; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ArchivedFilter) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArchivedFilter { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ArchivedFilter { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ARCHIVED_FILTER_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ARCHIVED_FILTER_EXCLUDE), + 2i32 => ::core::option::Option::Some(Self::ARCHIVED_FILTER_INCLUDE), + 3i32 => ::core::option::Option::Some(Self::ARCHIVED_FILTER_ONLY), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ARCHIVED_FILTER_UNSPECIFIED => "ARCHIVED_FILTER_UNSPECIFIED", + Self::ARCHIVED_FILTER_EXCLUDE => "ARCHIVED_FILTER_EXCLUDE", + Self::ARCHIVED_FILTER_INCLUDE => "ARCHIVED_FILTER_INCLUDE", + Self::ARCHIVED_FILTER_ONLY => "ARCHIVED_FILTER_ONLY", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ARCHIVED_FILTER_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ARCHIVED_FILTER_UNSPECIFIED) + } + "ARCHIVED_FILTER_EXCLUDE" => { + ::core::option::Option::Some(Self::ARCHIVED_FILTER_EXCLUDE) + } + "ARCHIVED_FILTER_INCLUDE" => { + ::core::option::Option::Some(Self::ARCHIVED_FILTER_INCLUDE) + } + "ARCHIVED_FILTER_ONLY" => { + ::core::option::Option::Some(Self::ARCHIVED_FILTER_ONLY) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ARCHIVED_FILTER_UNSPECIFIED, + Self::ARCHIVED_FILTER_EXCLUDE, + Self::ARCHIVED_FILTER_INCLUDE, + Self::ARCHIVED_FILTER_ONLY, + ] + } +} +/// ListSessionsRequest enumerates sessions in a scope, newest first. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListSessionsRequest { + /// Field 1: `accepted_contract` + #[serde(rename = "acceptedContract", alias = "accepted_contract")] + pub accepted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Field 2: `scope` + #[serde(rename = "scope", with = "::buffa::json_helpers::proto_enum")] + pub scope: ::buffa::EnumValue, + /// Required for SCOPE_WORKSPACE, ignored otherwise. + /// + /// Field 3: `workspace_id` + #[serde( + rename = "workspaceId", + alias = "workspace_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub workspace_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `archived` + #[serde(rename = "archived", with = "::buffa::json_helpers::proto_enum")] + pub archived: ::buffa::EnumValue, + /// Maximum rows to return. The server may return fewer. A value above the + /// configured admission limit is refused with + /// QUERY_ERROR_CODE_RESOURCE_EXHAUSTED rather than silently clamped, so a + /// caller is never left believing it asked for more than it received. + /// + /// Field 5: `page_size` + #[serde( + rename = "pageSize", + alias = "page_size", + with = "::buffa::json_helpers::uint32" + )] + pub page_size: u32, + /// Opaque continuation from a prior response, a serialized CursorEnvelope. + /// Unset starts a new scan. The caller must treat this as bytes and never + /// construct, parse, or edit one. + /// + /// A continuation still carries the scope, workspace, and archived filter, and + /// they must match what the cursor was minted with. The server refuses a + /// disagreement rather than re-scoping the scan in flight. + /// + /// Field 6: `page_token` + #[serde( + rename = "pageToken", + alias = "page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Freshness the caller requires. Honored when the scan opens and ignored on + /// a continuation, because a continuation is served from the pinned watermark + /// and waiting for anything newer could not change what it returns. + /// + /// A continuation whose requirement is stricter than the one the scan was + /// opened with is QUERY_ERROR_CODE_INVALID_ARGUMENT. Silently ignoring it + /// would let a caller believe a later page reflects a write that it cannot. + /// + /// Field 7: `consistency` + #[serde( + rename = "consistency", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub consistency: ::buffa::MessageField< + ReadConsistency, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ListSessionsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListSessionsRequest") + .field("accepted_contract", &self.accepted_contract) + .field("scope", &self.scope) + .field("workspace_id", &self.workspace_id) + .field("archived", &self.archived) + .field("page_size", &self.page_size) + .field("page_token", &self.page_token) + .field("consistency", &self.consistency) + .finish() + } +} +impl ListSessionsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest"; +} +impl ListSessionsRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::workspace_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_workspace_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.workspace_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ListSessionsRequest); +impl ::buffa::MessageName for ListSessionsRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListSessionsRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest"; +} +impl ::buffa::Message for ListSessionsRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.scope.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.archived.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.scope.to_i32(), buf); + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + ::buffa::types::put_int32_field(4u32, self.archived.to_i32(), buf); + ::buffa::types::put_uint32_field(5u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(6u32, v, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.accepted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.scope = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .workspace_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.archived = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.page_size = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self.page_token.get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.consistency.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.accepted_contract = ::buffa::MessageField::none(); + self.scope = ::buffa::EnumValue::from(0); + self.workspace_id = ::core::option::Option::None; + self.archived = ::buffa::EnumValue::from(0); + self.page_size = 0u32; + self.page_token = ::core::option::Option::None; + self.consistency = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListSessionsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_SESSIONS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ListSessionsResponse is one page of session summaries. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListSessionsResponse { + /// Field 1: `contract` + #[serde(rename = "contract")] + pub contract: ::buffa::MessageField< + ContractNegotiation, + ::buffa::Inline, + >, + /// Field 2: `sessions` + #[serde( + rename = "sessions", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub sessions: ::buffa::alloc::vec::Vec, + /// Unset when this is the last page. Presence, not an empty `sessions` list, + /// is the end-of-scan signal: a page may legitimately be empty while more + /// pages remain. + /// + /// Field 3: `next_page_token` + #[serde( + rename = "nextPageToken", + alias = "next_page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub next_page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Rows the server could not decode or render and therefore skipped. A + /// non-zero count means this page is incomplete, and a caller must not read + /// the result as an exhaustive list. Reporting zero is not the same as not + /// reporting. + /// + /// Field 4: `skipped_count` + #[serde( + rename = "skippedCount", + alias = "skipped_count", + with = "::buffa::json_helpers::uint32" + )] + pub skipped_count: u32, + /// The projection position this scan is pinned to, equal on every page of one + /// scan. It is the scan anchor, not a freshness report. + /// + /// A scan enumerates the ordering as it stood here, so a session that entered + /// the scope afterwards is not in it and will not appear on a later page. A + /// caller that needs newer rows starts a new scan; it does not keep paging and + /// wait for them to show up. + /// + /// Field 5: `pinned_watermark` + #[serde( + rename = "pinnedWatermark", + alias = "pinned_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub pinned_watermark: u64, + /// How current the read model was when the scan opened. Equal on every page, + /// since a pinned scan does not become fresher as it is paged. + /// + /// Field 6: `freshness` + #[serde(rename = "freshness")] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ListSessionsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListSessionsResponse") + .field("contract", &self.contract) + .field("sessions", &self.sessions) + .field("next_page_token", &self.next_page_token) + .field("skipped_count", &self.skipped_count) + .field("pinned_watermark", &self.pinned_watermark) + .field("freshness", &self.freshness) + .finish() + } +} +impl ListSessionsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse"; +} +impl ListSessionsResponse { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::next_page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_next_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.next_page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ListSessionsResponse); +impl ::buffa::MessageName for ListSessionsResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListSessionsResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse"; +} +impl ::buffa::Message for ListSessionsResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.sessions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.skipped_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.pinned_watermark) as u64; + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + for v in &self.sessions { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + ::buffa::types::put_uint32_field(4u32, self.skipped_count, buf); + ::buffa::types::put_uint64_field(5u32, self.pinned_watermark, buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.sessions.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self + .next_page_token + .get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.skipped_count = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.pinned_watermark = ::buffa::types::decode_uint64(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.contract = ::buffa::MessageField::none(); + self.sessions.clear(); + self.next_page_token = ::core::option::Option::None; + self.skipped_count = 0u32; + self.pinned_watermark = 0u64; + self.freshness = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListSessionsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_SESSIONS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListSessionsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.mod.rs new file mode 100644 index 0000000000..522d8f631a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.mod.rs @@ -0,0 +1,320 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.queries.v1alpha1.contract_version.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.projection_freshness.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.read_consistency.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.session_view.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.get_session.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.history_item.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.get_session_history.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.latest_session.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.list_sessions.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.page_cursor.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.presentation_cache.rs"); +include!("trogonai.session.sessions.queries.v1alpha1.query_error.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!( + "trogonai.session.sessions.queries.v1alpha1.contract_version.__view.rs" + ); + include!( + "trogonai.session.sessions.queries.v1alpha1.projection_freshness.__view.rs" + ); + include!( + "trogonai.session.sessions.queries.v1alpha1.read_consistency.__view.rs" + ); + include!("trogonai.session.sessions.queries.v1alpha1.session_view.__view.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.get_session.__view.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.history_item.__view.rs"); + include!( + "trogonai.session.sessions.queries.v1alpha1.get_session_history.__view.rs" + ); + include!("trogonai.session.sessions.queries.v1alpha1.latest_session.__view.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.list_sessions.__view.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.page_cursor.__view.rs"); + include!( + "trogonai.session.sessions.queries.v1alpha1.presentation_cache.__view.rs" + ); + include!("trogonai.session.sessions.queries.v1alpha1.query_error.__view.rs"); + pub mod oneof { + #[allow(unused_imports)] + use super::*; + include!( + "trogonai.session.sessions.queries.v1alpha1.history_item.__view_oneof.rs" + ); + include!( + "trogonai.session.sessions.queries.v1alpha1.page_cursor.__view_oneof.rs" + ); + include!( + "trogonai.session.sessions.queries.v1alpha1.query_error.__view_oneof.rs" + ); + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.queries.v1alpha1.history_item.__oneof.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.page_cursor.__oneof.rs"); + include!("trogonai.session.sessions.queries.v1alpha1.query_error.__oneof.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__CONTRACT_VERSION_JSON_ANY); + reg.register_json_any(super::__CONTRACT_NEGOTIATION_JSON_ANY); + reg.register_json_any(super::__PROJECTION_FRESHNESS_JSON_ANY); + reg.register_json_any(super::__CONSISTENCY_OUTCOME_JSON_ANY); + reg.register_json_any(super::__READ_CONSISTENCY_JSON_ANY); + reg.register_json_any(super::__CONSISTENCY_TOKEN_JSON_ANY); + reg.register_json_any(super::__SESSION_SUMMARY_JSON_ANY); + reg.register_json_any(super::__SESSION_PREVIEW_JSON_ANY); + reg.register_json_any(super::__RECOVERY_PROVENANCE_VIEW_JSON_ANY); + reg.register_json_any(super::__SESSION_VIEW_JSON_ANY); + reg.register_json_any(super::__ARTIFACT_COMPLETENESS_VIEW_JSON_ANY); + reg.register_json_any(super::__OBSERVED_INTEGRITY_VIEW_JSON_ANY); + reg.register_json_any(super::__FORK_ORIGIN_VIEW_JSON_ANY); + reg.register_json_any(super::__PARENT_VIEW_JSON_ANY); + reg.register_json_any(super::__DELEGATION_VIEW_JSON_ANY); + reg.register_json_any(super::__GET_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_SESSION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__HISTORY_ITEM_JSON_ANY); + reg.register_json_any(super::__HISTORY_ITEM_ELIDED_JSON_ANY); + reg.register_json_any(super::__USER_MESSAGE_ITEM_JSON_ANY); + reg.register_json_any(super::__ASSISTANT_MESSAGE_ITEM_JSON_ANY); + reg.register_json_any(super::__TOOL_CALL_ITEM_JSON_ANY); + reg.register_json_any(super::__FILE_CHANGE_ITEM_JSON_ANY); + reg.register_json_any(super::__SYSTEM_NOTICE_ITEM_JSON_ANY); + reg.register_json_any(super::__COMPACTION_ITEM_JSON_ANY); + reg.register_json_any(super::__GET_SESSION_HISTORY_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_SESSION_HISTORY_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_LATEST_SESSION_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_LATEST_SESSION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__EXCLUSION_COUNTS_JSON_ANY); + reg.register_json_any(super::__LIST_SESSIONS_REQUEST_JSON_ANY); + reg.register_json_any(super::__LIST_SESSIONS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__CURSOR_ENVELOPE_JSON_ANY); + reg.register_json_any(super::__PAGE_CURSOR_JSON_ANY); + reg.register_json_any(super::__HISTORY_SCAN_CURSOR_JSON_ANY); + reg.register_json_any(super::__SESSION_LIST_SCAN_CURSOR_JSON_ANY); + reg.register_json_any(super::__LIST_SCAN_SELECTOR_JSON_ANY); + reg.register_json_any(super::__SESSION_ORDERING_KEY_JSON_ANY); + reg.register_json_any(super::__CURSOR_VALIDITY_JSON_ANY); + reg.register_json_any(super::__PRESENTATION_CACHE_BINDING_JSON_ANY); + reg.register_json_any(super::__CHECK_PRESENTATION_CACHE_REQUEST_JSON_ANY); + reg.register_json_any(super::__CHECK_PRESENTATION_CACHE_RESPONSE_JSON_ANY); + reg.register_json_any(super::__QUERY_ERROR_JSON_ANY); + reg.register_json_any(super::__UNSUPPORTED_CONTRACT_VERSION_DETAIL_JSON_ANY); + reg.register_json_any(super::__STALE_CURSOR_DETAIL_JSON_ANY); + reg.register_json_any(super::__PROJECTION_UNAVAILABLE_DETAIL_JSON_ANY); + reg.register_json_any(super::__REBUILD_PROGRESS_JSON_ANY); + reg.register_json_any(super::__INVALID_ARGUMENT_DETAIL_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::ContractVersionView; +#[doc(inline)] +pub use self::__buffa::view::ContractVersionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ContractNegotiationView; +#[doc(inline)] +pub use self::__buffa::view::ContractNegotiationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionFreshnessView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionFreshnessOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ConsistencyOutcomeView; +#[doc(inline)] +pub use self::__buffa::view::ConsistencyOutcomeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReadConsistencyView; +#[doc(inline)] +pub use self::__buffa::view::ReadConsistencyOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ConsistencyTokenView; +#[doc(inline)] +pub use self::__buffa::view::ConsistencyTokenOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SessionSummaryView; +#[doc(inline)] +pub use self::__buffa::view::SessionSummaryOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SessionPreviewView; +#[doc(inline)] +pub use self::__buffa::view::SessionPreviewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecoveryProvenanceViewView; +#[doc(inline)] +pub use self::__buffa::view::RecoveryProvenanceViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SessionViewView; +#[doc(inline)] +pub use self::__buffa::view::SessionViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ArtifactCompletenessViewView; +#[doc(inline)] +pub use self::__buffa::view::ArtifactCompletenessViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ObservedIntegrityViewView; +#[doc(inline)] +pub use self::__buffa::view::ObservedIntegrityViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ForkOriginViewView; +#[doc(inline)] +pub use self::__buffa::view::ForkOriginViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ParentViewView; +#[doc(inline)] +pub use self::__buffa::view::ParentViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DelegationViewView; +#[doc(inline)] +pub use self::__buffa::view::DelegationViewOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::HistoryItemView; +#[doc(inline)] +pub use self::__buffa::view::HistoryItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::HistoryItemElidedView; +#[doc(inline)] +pub use self::__buffa::view::HistoryItemElidedOwnedView; +#[doc(inline)] +pub use self::__buffa::view::UserMessageItemView; +#[doc(inline)] +pub use self::__buffa::view::UserMessageItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::AssistantMessageItemView; +#[doc(inline)] +pub use self::__buffa::view::AssistantMessageItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ToolCallItemView; +#[doc(inline)] +pub use self::__buffa::view::ToolCallItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::FileChangeItemView; +#[doc(inline)] +pub use self::__buffa::view::FileChangeItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SystemNoticeItemView; +#[doc(inline)] +pub use self::__buffa::view::SystemNoticeItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CompactionItemView; +#[doc(inline)] +pub use self::__buffa::view::CompactionItemOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionHistoryRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionHistoryRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionHistoryResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetSessionHistoryResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetLatestSessionRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetLatestSessionRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::GetLatestSessionResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetLatestSessionResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ExclusionCountsView; +#[doc(inline)] +pub use self::__buffa::view::ExclusionCountsOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ListSessionsRequestView; +#[doc(inline)] +pub use self::__buffa::view::ListSessionsRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ListSessionsResponseView; +#[doc(inline)] +pub use self::__buffa::view::ListSessionsResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CursorEnvelopeView; +#[doc(inline)] +pub use self::__buffa::view::CursorEnvelopeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::PageCursorView; +#[doc(inline)] +pub use self::__buffa::view::PageCursorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::HistoryScanCursorView; +#[doc(inline)] +pub use self::__buffa::view::HistoryScanCursorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SessionListScanCursorView; +#[doc(inline)] +pub use self::__buffa::view::SessionListScanCursorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ListScanSelectorView; +#[doc(inline)] +pub use self::__buffa::view::ListScanSelectorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SessionOrderingKeyView; +#[doc(inline)] +pub use self::__buffa::view::SessionOrderingKeyOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CursorValidityView; +#[doc(inline)] +pub use self::__buffa::view::CursorValidityOwnedView; +#[doc(inline)] +pub use self::__buffa::view::PresentationCacheBindingView; +#[doc(inline)] +pub use self::__buffa::view::PresentationCacheBindingOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CheckPresentationCacheRequestView; +#[doc(inline)] +pub use self::__buffa::view::CheckPresentationCacheRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CheckPresentationCacheResponseView; +#[doc(inline)] +pub use self::__buffa::view::CheckPresentationCacheResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::QueryErrorView; +#[doc(inline)] +pub use self::__buffa::view::QueryErrorOwnedView; +#[doc(inline)] +pub use self::__buffa::view::UnsupportedContractVersionDetailView; +#[doc(inline)] +pub use self::__buffa::view::UnsupportedContractVersionDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StaleCursorDetailView; +#[doc(inline)] +pub use self::__buffa::view::StaleCursorDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionUnavailableDetailView; +#[doc(inline)] +pub use self::__buffa::view::ProjectionUnavailableDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RebuildProgressView; +#[doc(inline)] +pub use self::__buffa::view::RebuildProgressOwnedView; +#[doc(inline)] +pub use self::__buffa::view::InvalidArgumentDetailView; +#[doc(inline)] +pub use self::__buffa::view::InvalidArgumentDetailOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__oneof.rs new file mode 100644 index 0000000000..3263da166e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__oneof.rs @@ -0,0 +1,57 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/page_cursor.proto + +pub mod page_cursor { + #[allow(unused_imports)] + use super::*; + /// When the scan variant does not match the query it was presented to, the + /// token is MALFORMED_CURSOR. A history cursor is not a list cursor with + /// different fields set. + #[derive(Clone, PartialEq, Debug)] + pub enum Scan { + History(::buffa::alloc::boxed::Box), + SessionList( + ::buffa::alloc::boxed::Box, + ), + } + impl ::buffa::Oneof for Scan {} + impl From for Scan { + fn from(v: super::super::super::HistoryScanCursor) -> Self { + Self::History(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::HistoryScanCursor) -> Self { + Self::Some(Scan::from(v)) + } + } + impl From for Scan { + fn from(v: super::super::super::SessionListScanCursor) -> Self { + Self::SessionList(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::SessionListScanCursor) -> Self { + Self::Some(Scan::from(v)) + } + } + impl serde::Serialize for Scan { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::History(v) => { + map.serialize_entry("history", v)?; + } + Self::SessionList(v) => { + map.serialize_entry("sessionList", v)?; + } + } + map.end() + } + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view.rs new file mode 100644 index 0000000000..4482a9403f --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view.rs @@ -0,0 +1,2917 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/page_cursor.proto + +/// CursorEnvelope is what a `page_token` actually contains. +/// +/// These types are server-minted internals. They are published so the format is +/// reviewable and versioned, not so callers can read it: a client must treat a +/// token as opaque bytes and never construct, parse, or edit one. The server +/// owes nothing to a hand-built token beyond QUERY_ERROR_CODE_MALFORMED_CURSOR. +/// +/// The envelope keeps `payload` as bytes rather than an inline message on +/// purpose. `mac` authenticates the exact bytes the server emitted, and protobuf +/// serialization is not canonical, so a server that re-encoded a decoded message +/// to check the MAC could compute a different byte string than it signed. +#[derive(Clone, Debug, Default)] +pub struct CursorEnvelopeView<'a> { + /// Version of this envelope and payload format, independent of the query + /// ContractVersion. A token minted under an unknown format_version is + /// MALFORMED_CURSOR, not STALE_CURSOR: there is nothing to interpret. + /// + /// Field 1: `format_version` + pub format_version: u32, + /// Serialized PageCursor. + /// + /// Field 2: `payload` + pub payload: &'a [u8], + /// Authenticates format_version and payload under a server-held key. + /// + /// A cursor names a scan position, so an unauthenticated one is a request + /// parameter the caller controls. The MAC is what stops a caller from moving + /// the anchor, widening the selector, or pointing a scan at another session's + /// stream. It is tamper evidence and nothing more: a cursor is never + /// authorization, and every continuation is re-authorized from the caller's + /// own identity as if it were a fresh request. + /// + /// Field 3: `mac` + pub mac: &'a [u8], + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CursorEnvelopeView<'a> { + /**Whether required field `format_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_format_version(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `payload` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_payload(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `mac` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_mac(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CursorEnvelopeView<'a> { + type Owned = super::super::CursorEnvelope; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.format_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.payload = ::buffa::types::borrow_bytes(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.mac = ::buffa::types::borrow_bytes(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CursorEnvelope { + format_version: self.format_version, + payload: (self.payload).to_vec(), + mac: (self.mac).to_vec(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CursorEnvelopeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.payload) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.mac) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.format_version, buf); + ::buffa::types::put_shared_bytes_field(2u32, &self.payload, buf); + ::buffa::types::put_shared_bytes_field(3u32, &self.mac, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CursorEnvelopeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "formatVersion", + &::buffa::json_helpers::ProtoJson(&self.format_version), + )?; + } + { + __map + .serialize_entry( + "payload", + &::buffa::json_helpers::BytesJson(self.payload), + )?; + } + { + __map.serialize_entry("mac", &::buffa::json_helpers::BytesJson(self.mac))?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CursorEnvelopeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CursorEnvelope"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CursorEnvelope"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorEnvelope"; +} +::buffa::impl_default_view_instance!(CursorEnvelopeView); +::buffa::impl_view_reborrow!(CursorEnvelopeView); +/** Self-contained, `'static` owned view of a `CursorEnvelope` message. + + Wraps [`::buffa::OwnedView`]`<`[`CursorEnvelopeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CursorEnvelopeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CursorEnvelopeOwnedView(::buffa::OwnedView>); +impl CursorEnvelopeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorEnvelopeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorEnvelopeOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CursorEnvelope, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorEnvelopeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CursorEnvelopeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CursorEnvelopeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CursorEnvelope { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Version of this envelope and payload format, independent of the query + /// ContractVersion. A token minted under an unknown format_version is + /// MALFORMED_CURSOR, not STALE_CURSOR: there is nothing to interpret. + /// + /// Field 1: `format_version` + #[must_use] + pub fn format_version(&self) -> u32 { + self.0.reborrow().format_version + } + /// Serialized PageCursor. + /// + /// Field 2: `payload` + #[must_use] + pub fn payload(&self) -> &'_ [u8] { + self.0.reborrow().payload + } + /// Authenticates format_version and payload under a server-held key. + /// + /// A cursor names a scan position, so an unauthenticated one is a request + /// parameter the caller controls. The MAC is what stops a caller from moving + /// the anchor, widening the selector, or pointing a scan at another session's + /// stream. It is tamper evidence and nothing more: a cursor is never + /// authorization, and every continuation is re-authorized from the caller's + /// own identity as if it were a fresh request. + /// + /// Field 3: `mac` + #[must_use] + pub fn mac(&self) -> &'_ [u8] { + self.0.reborrow().mac + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CursorEnvelopeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CursorEnvelopeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CursorEnvelopeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CursorEnvelopeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CursorEnvelope { + type View<'a> = CursorEnvelopeView<'a>; + type ViewHandle = CursorEnvelopeOwnedView; +} +impl ::serde::Serialize for CursorEnvelopeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// PageCursor is the decoded scan position. +#[derive(Clone, Debug, Default)] +pub struct PageCursorView<'a> { + /// When the token stops being honored regardless of validity. + /// + /// A pinned scan holds read-model retention (see CursorValidity), so scans + /// cannot be allowed to live forever. Expiry is STALE_CURSOR with + /// STALE_CURSOR_REASON_EXPIRED, because restarting the scan is the fix. + /// + /// Field 3: `expires_at` + pub expires_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + pub scan: ::core::option::Option< + super::super::__buffa::view::oneof::page_cursor::Scan<'a>, + >, +} +impl<'a> PageCursorView<'a> { + /**Whether required field `expires_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_expires_at(&self) -> bool { + self.expires_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for PageCursorView<'a> { + type Owned = super::super::PageCursor; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.expires_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.expires_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::page_cursor::Scan::History( + ref mut existing, + ), + ) = view.scan + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.scan = Some( + super::super::__buffa::view::oneof::page_cursor::Scan::History( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + ref mut existing, + ), + ) = view.scan + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.scan = Some( + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::PageCursor { + expires_at: match self.expires_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + scan: match self.scan.as_ref() { + ::core::option::Option::Some(v) => { + ::core::option::Option::Some( + match v { + super::super::__buffa::view::oneof::page_cursor::Scan::History( + v, + ) => { + super::super::__buffa::oneof::page_cursor::Scan::History( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + v, + ) => { + super::super::__buffa::oneof::page_cursor::Scan::SessionList( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + }, + ) + } + ::core::option::Option::None => ::core::option::Option::None, + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for PageCursorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.scan { + match v { + super::super::__buffa::view::oneof::page_cursor::Scan::History(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + if self.expires_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expires_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.scan { + match v { + super::super::__buffa::view::oneof::page_cursor::Scan::History(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + if self.expires_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expires_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for PageCursorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.expires_at.as_option() { + __map.serialize_entry("expiresAt", __v)?; + } + } + if let ::core::option::Option::Some(ref __ov) = self.scan { + match __ov { + super::super::__buffa::view::oneof::page_cursor::Scan::History(v) => { + __map.serialize_entry("history", v)?; + } + super::super::__buffa::view::oneof::page_cursor::Scan::SessionList( + v, + ) => { + __map.serialize_entry("sessionList", v)?; + } + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for PageCursorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "PageCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.PageCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PageCursor"; +} +::buffa::impl_default_view_instance!(PageCursorView); +::buffa::impl_view_reborrow!(PageCursorView); +/** Self-contained, `'static` owned view of a `PageCursor` message. + + Wraps [`::buffa::OwnedView`]`<`[`PageCursorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`PageCursorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct PageCursorOwnedView(::buffa::OwnedView>); +impl PageCursorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PageCursorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PageCursorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::PageCursor, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PageCursorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`PageCursorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &PageCursorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::PageCursor { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// When the token stops being honored regardless of validity. + /// + /// A pinned scan holds read-model retention (see CursorValidity), so scans + /// cannot be allowed to live forever. Expiry is STALE_CURSOR with + /// STALE_CURSOR_REASON_EXPIRED, because restarting the scan is the fix. + /// + /// Field 3: `expires_at` + #[must_use] + pub fn expires_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().expires_at + } + /// Oneof `scan`. + #[must_use] + pub fn scan( + &self, + ) -> ::core::option::Option< + &super::super::__buffa::view::oneof::page_cursor::Scan<'_>, + > { + self.0.reborrow().scan.as_ref() + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for PageCursorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + PageCursorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: PageCursorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for PageCursorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::PageCursor { + type View<'a> = PageCursorView<'a>; + type ViewHandle = PageCursorOwnedView; +} +impl ::serde::Serialize for PageCursorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// HistoryScanCursor is a position within one session's history. +/// +/// This is the message that makes the paging guarantee true. History is +/// append-only and every item carries a SessionOrdinal that is assigned once and +/// never renumbered, so a position expressed as an ordinal keeps its meaning as +/// the session grows. A position expressed as an offset from either end does +/// not, which is why the count of items is deliberately absent here. +#[derive(Clone, Debug, Default)] +pub struct HistoryScanCursorView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Contract the scan was opened at. The server keeps rendering at this version + /// for the life of the scan so a page is not shaped differently from its + /// predecessors. A continuation presenting a different major is + /// STALE_CURSOR_REASON_CONTRACT_CHANGED. + /// + /// Field 2: `minted_contract` + pub minted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Fixed for the life of the scan. A continuation cannot reverse it; that is a + /// new scan. + /// + /// Field 3: `direction` + pub direction: ::buffa::EnumValue, + /// The effective-history head the scan was pinned to when it opened, as a + /// SessionOrdinal. + /// + /// The scan never looks past this, and that is what makes concurrent appends + /// harmless: a turn recorded after the scan opened is outside the window + /// rather than shifting rows inside it. A reverse scan walking toward older + /// history is unaffected by definition; a forward scan ends here even if newer + /// items exist by the time it arrives. + /// + /// Field 4: `anchor_ordinal` + pub anchor_ordinal: u64, + /// The last SessionOrdinal delivered. The next page resumes strictly past it + /// in `direction`, which is why an item can be neither repeated nor skipped: + /// the boundary is the identity of a delivered row, not a count of them. + /// + /// Field 5: `last_delivered_ordinal` + pub last_delivered_ordinal: u64, + /// Field 6: `validity` + pub validity: ::buffa::MessageFieldView< + super::super::__buffa::view::CursorValidityView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> HistoryScanCursorView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `minted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_minted_contract(&self) -> bool { + self.minted_contract.is_set() + } + /**Whether required field `direction` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_direction(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `anchor_ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_anchor_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `last_delivered_ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_last_delivered_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `validity` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_validity(&self) -> bool { + self.validity.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for HistoryScanCursorView<'a> { + type Owned = super::super::HistoryScanCursor; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.minted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.minted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.direction = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.anchor_ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.last_delivered_ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.validity.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.validity = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::HistoryScanCursor { + session_id: self.session_id.to_string(), + minted_contract: match self.minted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + direction: self.direction, + anchor_ordinal: self.anchor_ordinal, + last_delivered_ordinal: self.last_delivered_ordinal, + validity: match self.validity.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CursorValidity, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for HistoryScanCursorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.minted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.direction.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.anchor_ordinal) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.last_delivered_ordinal) as u64; + if self.validity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.validity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.minted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.direction.to_i32(), buf); + ::buffa::types::put_uint64_field(4u32, self.anchor_ordinal, buf); + ::buffa::types::put_uint64_field(5u32, self.last_delivered_ordinal, buf); + if self.validity.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.validity.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for HistoryScanCursorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.minted_contract.as_option() { + __map.serialize_entry("mintedContract", __v)?; + } + } + { + __map.serialize_entry("direction", &self.direction)?; + } + { + __map + .serialize_entry( + "anchorOrdinal", + &::buffa::json_helpers::ProtoJson(&self.anchor_ordinal), + )?; + } + { + __map + .serialize_entry( + "lastDeliveredOrdinal", + &::buffa::json_helpers::ProtoJson(&self.last_delivered_ordinal), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.validity.as_option() { + __map.serialize_entry("validity", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for HistoryScanCursorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryScanCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor"; +} +::buffa::impl_default_view_instance!(HistoryScanCursorView); +::buffa::impl_view_reborrow!(HistoryScanCursorView); +/** Self-contained, `'static` owned view of a `HistoryScanCursor` message. + + Wraps [`::buffa::OwnedView`]`<`[`HistoryScanCursorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`HistoryScanCursorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct HistoryScanCursorOwnedView( + ::buffa::OwnedView>, +); +impl HistoryScanCursorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryScanCursorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryScanCursorOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::HistoryScanCursor, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HistoryScanCursorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`HistoryScanCursorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &HistoryScanCursorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::HistoryScanCursor { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Contract the scan was opened at. The server keeps rendering at this version + /// for the life of the scan so a page is not shaped differently from its + /// predecessors. A continuation presenting a different major is + /// STALE_CURSOR_REASON_CONTRACT_CHANGED. + /// + /// Field 2: `minted_contract` + #[must_use] + pub fn minted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().minted_contract + } + /// Fixed for the life of the scan. A continuation cannot reverse it; that is a + /// new scan. + /// + /// Field 3: `direction` + #[must_use] + pub fn direction(&self) -> ::buffa::EnumValue { + self.0.reborrow().direction + } + /// The effective-history head the scan was pinned to when it opened, as a + /// SessionOrdinal. + /// + /// The scan never looks past this, and that is what makes concurrent appends + /// harmless: a turn recorded after the scan opened is outside the window + /// rather than shifting rows inside it. A reverse scan walking toward older + /// history is unaffected by definition; a forward scan ends here even if newer + /// items exist by the time it arrives. + /// + /// Field 4: `anchor_ordinal` + #[must_use] + pub fn anchor_ordinal(&self) -> u64 { + self.0.reborrow().anchor_ordinal + } + /// The last SessionOrdinal delivered. The next page resumes strictly past it + /// in `direction`, which is why an item can be neither repeated nor skipped: + /// the boundary is the identity of a delivered row, not a count of them. + /// + /// Field 5: `last_delivered_ordinal` + #[must_use] + pub fn last_delivered_ordinal(&self) -> u64 { + self.0.reborrow().last_delivered_ordinal + } + /// Field 6: `validity` + #[must_use] + pub fn validity( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CursorValidityView<'_>, + > { + &self.0.reborrow().validity + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for HistoryScanCursorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + HistoryScanCursorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: HistoryScanCursorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for HistoryScanCursorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::HistoryScanCursor { + type View<'a> = HistoryScanCursorView<'a>; + type ViewHandle = HistoryScanCursorOwnedView; +} +impl ::serde::Serialize for HistoryScanCursorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SessionListScanCursor is a position within a list scan. +#[derive(Clone, Debug, Default)] +pub struct SessionListScanCursorView<'a> { + /// Field 1: `minted_contract` + pub minted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Field 2: `selector` + pub selector: ::buffa::MessageFieldView< + super::super::__buffa::view::ListScanSelectorView<'a>, + >, + /// Last row delivered. The next page resumes strictly after it in the scan's + /// ordering. + /// + /// Field 3: `last_delivered` + pub last_delivered: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrderingKeyView<'a>, + >, + /// Field 4: `validity` + pub validity: ::buffa::MessageFieldView< + super::super::__buffa::view::CursorValidityView<'a>, + >, +} +impl<'a> SessionListScanCursorView<'a> { + /**Whether required field `minted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_minted_contract(&self) -> bool { + self.minted_contract.is_set() + } + /**Whether required field `selector` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_selector(&self) -> bool { + self.selector.is_set() + } + /**Whether required field `last_delivered` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_last_delivered(&self) -> bool { + self.last_delivered.is_set() + } + /**Whether required field `validity` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_validity(&self) -> bool { + self.validity.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SessionListScanCursorView<'a> { + type Owned = super::super::SessionListScanCursor; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.minted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.minted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.selector.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.selector = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.last_delivered.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.last_delivered = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.validity.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.validity = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::SessionListScanCursor, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::SessionListScanCursor, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionListScanCursor { + minted_contract: match self.minted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + selector: match self.selector.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ListScanSelector, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + last_delivered: match self.last_delivered.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrderingKey, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + validity: match self.validity.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CursorValidity, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionListScanCursorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.minted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.selector.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.selector.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.last_delivered.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.last_delivered.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.validity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.validity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.minted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minted_contract.write_to(__cache, buf); + } + if self.selector.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.selector.write_to(__cache, buf); + } + if self.last_delivered.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.last_delivered.write_to(__cache, buf); + } + if self.validity.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.validity.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionListScanCursorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.minted_contract.as_option() { + __map.serialize_entry("mintedContract", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.selector.as_option() { + __map.serialize_entry("selector", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.last_delivered.as_option() { + __map.serialize_entry("lastDelivered", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.validity.as_option() { + __map.serialize_entry("validity", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionListScanCursorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionListScanCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor"; +} +::buffa::impl_default_view_instance!(SessionListScanCursorView); +::buffa::impl_view_reborrow!(SessionListScanCursorView); +/** Self-contained, `'static` owned view of a `SessionListScanCursor` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionListScanCursorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionListScanCursorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionListScanCursorOwnedView( + ::buffa::OwnedView>, +); +impl SessionListScanCursorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionListScanCursorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionListScanCursorOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionListScanCursor, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionListScanCursorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionListScanCursorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionListScanCursorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionListScanCursor { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `minted_contract` + #[must_use] + pub fn minted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().minted_contract + } + /// Field 2: `selector` + #[must_use] + pub fn selector( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ListScanSelectorView<'_>, + > { + &self.0.reborrow().selector + } + /// Last row delivered. The next page resumes strictly after it in the scan's + /// ordering. + /// + /// Field 3: `last_delivered` + #[must_use] + pub fn last_delivered( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrderingKeyView<'_>, + > { + &self.0.reborrow().last_delivered + } + /// Field 4: `validity` + #[must_use] + pub fn validity( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CursorValidityView<'_>, + > { + &self.0.reborrow().validity + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionListScanCursorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionListScanCursorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionListScanCursorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionListScanCursorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionListScanCursor { + type View<'a> = SessionListScanCursorView<'a>; + type ViewHandle = SessionListScanCursorOwnedView; +} +impl ::serde::Serialize for SessionListScanCursorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ListScanSelector is the request shape the scan was opened with. +/// +/// A continuation whose request disagrees with this is MALFORMED_CURSOR rather +/// than a silently re-scoped scan. Changing the scope, workspace, or archived +/// filter mid-scan produces a page sequence that is neither the old selection +/// nor the new one, and the caller has no way to notice. +#[derive(Clone, Debug, Default)] +pub struct ListScanSelectorView<'a> { + /// Field 1: `scope` + pub scope: ::buffa::EnumValue, + /// Field 2: `workspace_id` + pub workspace_id: ::core::option::Option<&'a str>, + /// Field 3: `archived` + pub archived: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ListScanSelectorView<'a> { + /**Whether required field `scope` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_scope(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `archived` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_archived(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ListScanSelectorView<'a> { + type Owned = super::super::ListScanSelector; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.scope = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.workspace_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.archived = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ListScanSelector { + scope: self.scope, + workspace_id: self.workspace_id.map(|s| s.to_string()), + archived: self.archived, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ListScanSelectorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.scope.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.archived.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.scope.to_i32(), buf); + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(2u32, v, buf); + } + ::buffa::types::put_int32_field(3u32, self.archived.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ListScanSelectorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("scope", &self.scope)?; + } + if let ::core::option::Option::Some(__v) = self.workspace_id { + __map.serialize_entry("workspaceId", __v)?; + } + { + __map.serialize_entry("archived", &self.archived)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ListScanSelectorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListScanSelector"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListScanSelector"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListScanSelector"; +} +::buffa::impl_default_view_instance!(ListScanSelectorView); +::buffa::impl_view_reborrow!(ListScanSelectorView); +/** Self-contained, `'static` owned view of a `ListScanSelector` message. + + Wraps [`::buffa::OwnedView`]`<`[`ListScanSelectorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ListScanSelectorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ListScanSelectorOwnedView(::buffa::OwnedView>); +impl ListScanSelectorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListScanSelectorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListScanSelectorOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ListScanSelector, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ListScanSelectorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ListScanSelectorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ListScanSelectorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ListScanSelector { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `scope` + #[must_use] + pub fn scope(&self) -> ::buffa::EnumValue { + self.0.reborrow().scope + } + /// Field 2: `workspace_id` + #[must_use] + pub fn workspace_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().workspace_id + } + /// Field 3: `archived` + #[must_use] + pub fn archived(&self) -> ::buffa::EnumValue { + self.0.reborrow().archived + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ListScanSelectorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ListScanSelectorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ListScanSelectorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ListScanSelectorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ListScanSelector { + type View<'a> = ListScanSelectorView<'a>; + type ViewHandle = ListScanSelectorOwnedView; +} +impl ::serde::Serialize for ListScanSelectorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SessionOrderingKey is one row's position in the list ordering. +/// +/// Ordering is by `ordering_value` descending, then `session_id` ascending. The +/// tie-breaker is not decoration: ordering values collide, and a boundary that +/// cannot distinguish two rows sharing one must either re-emit both or drop +/// both. +#[derive(Clone, Debug, Default)] +pub struct SessionOrderingKeyView<'a> { + /// The row's ordering value as of the scan's pinned watermark, not as of now. + /// + /// Recency ordering is the thing a session picker wants and is also mutable, a + /// combination that breaks naive pagination: a row that gains activity after + /// the cursor has passed its old position jumps ahead of the cursor and is + /// never delivered. Reading the ordering as of a fixed watermark is what + /// removes that skip, and it is an obligation on the list projection rather + /// than something this contract can assert by itself. + /// + /// Field 1: `ordering_value` + pub ordering_value: u64, + /// Field 2: `session_id` + pub session_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SessionOrderingKeyView<'a> { + /**Whether required field `ordering_value` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ordering_value(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SessionOrderingKeyView<'a> { + type Owned = super::super::SessionOrderingKey; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordering_value = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionOrderingKey { + ordering_value: self.ordering_value, + session_id: self.session_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionOrderingKeyView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordering_value) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.ordering_value, buf); + ::buffa::types::put_string_field(2u32, &self.session_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionOrderingKeyView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "orderingValue", + &::buffa::json_helpers::ProtoJson(&self.ordering_value), + )?; + } + { + __map.serialize_entry("sessionId", self.session_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionOrderingKeyView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionOrderingKey"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey"; +} +::buffa::impl_default_view_instance!(SessionOrderingKeyView); +::buffa::impl_view_reborrow!(SessionOrderingKeyView); +/** Self-contained, `'static` owned view of a `SessionOrderingKey` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionOrderingKeyView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionOrderingKeyView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionOrderingKeyOwnedView( + ::buffa::OwnedView>, +); +impl SessionOrderingKeyOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionOrderingKeyOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionOrderingKeyOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionOrderingKey, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionOrderingKeyOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionOrderingKeyView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionOrderingKeyView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionOrderingKey { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The row's ordering value as of the scan's pinned watermark, not as of now. + /// + /// Recency ordering is the thing a session picker wants and is also mutable, a + /// combination that breaks naive pagination: a row that gains activity after + /// the cursor has passed its old position jumps ahead of the cursor and is + /// never delivered. Reading the ordering as of a fixed watermark is what + /// removes that skip, and it is an obligation on the list projection rather + /// than something this contract can assert by itself. + /// + /// Field 1: `ordering_value` + #[must_use] + pub fn ordering_value(&self) -> u64 { + self.0.reborrow().ordering_value + } + /// Field 2: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionOrderingKeyOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionOrderingKeyOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionOrderingKeyOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionOrderingKeyOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionOrderingKey { + type View<'a> = SessionOrderingKeyView<'a>; + type ViewHandle = SessionOrderingKeyOwnedView; +} +impl ::serde::Serialize for SessionOrderingKeyOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// CursorValidity is everything a cursor binds to besides its position. +/// +/// Each field answers one question: is the sequence this cursor was cut from +/// still the same sequence? A change in any of them means resuming would produce +/// a page sequence that never existed as a whole, so the server refuses with +/// QUERY_ERROR_CODE_STALE_CURSOR and the matching StaleCursorReason instead of +/// serving a plausible page. +#[derive(Clone, Debug, Default)] +pub struct CursorValidityView<'a> { + /// Identifies the projection instance. A rebuild under a new generation makes + /// ordering values from the old one meaningless. + /// Mismatch: STALE_CURSOR_REASON_PROJECTION_REPLACED. + /// + /// Field 1: `projection_generation` + pub projection_generation: &'a str, + /// The projection position the scan is pinned to. Constant across every page + /// of one scan. + /// + /// A pinned scan requires the projection to still be able to answer as of this + /// point, which is what cursor expiry bounds. + /// + /// Field 2: `pinned_watermark` + pub pinned_watermark: u64, + /// Bumped whenever the set of effective events changes shape: rewind, which + /// retracts history the scan may already have passed, and compaction, which + /// replaces a span with a summary. Either leaves a cursor describing a prefix + /// that no longer exists. + /// + /// Mismatch is STALE_CURSOR_REASON_REWOUND or STALE_CURSOR_REASON_COMPACTED + /// depending on which change advanced it, so the server must know the cause of + /// an advance and not only that one happened. The distinction matters to a + /// caller: a compaction lost nothing, a rewind did. + /// + /// Field 3: `effective_history_revision` + pub effective_history_revision: u64, + /// Bumped by redaction and artifact erasure. Tracked separately from + /// effective_history_revision because it is the field that must be checked + /// even when nothing else moved: continuing to serve a scan cut before an + /// erasure would keep handing out content that was ordered destroyed. + /// Mismatch: STALE_CURSOR_REASON_PRIVACY_CHANGED. + /// + /// Field 4: `privacy_revision` + pub privacy_revision: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CursorValidityView<'a> { + /**Whether required field `projection_generation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projection_generation(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `pinned_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_pinned_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `effective_history_revision` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_effective_history_revision(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `privacy_revision` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_privacy_revision(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CursorValidityView<'a> { + type Owned = super::super::CursorValidity; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.projection_generation = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.pinned_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.effective_history_revision = ::buffa::types::decode_uint64( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.privacy_revision = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CursorValidity { + projection_generation: self.projection_generation.to_string(), + pinned_watermark: self.pinned_watermark, + effective_history_revision: self.effective_history_revision, + privacy_revision: self.privacy_revision, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CursorValidityView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.pinned_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.effective_history_revision) + as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.privacy_revision) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(2u32, self.pinned_watermark, buf); + ::buffa::types::put_uint64_field(3u32, self.effective_history_revision, buf); + ::buffa::types::put_uint64_field(4u32, self.privacy_revision, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CursorValidityView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("projectionGeneration", self.projection_generation)?; + } + { + __map + .serialize_entry( + "pinnedWatermark", + &::buffa::json_helpers::ProtoJson(&self.pinned_watermark), + )?; + } + { + __map + .serialize_entry( + "effectiveHistoryRevision", + &::buffa::json_helpers::ProtoJson(&self.effective_history_revision), + )?; + } + { + __map + .serialize_entry( + "privacyRevision", + &::buffa::json_helpers::ProtoJson(&self.privacy_revision), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CursorValidityView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CursorValidity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CursorValidity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorValidity"; +} +::buffa::impl_default_view_instance!(CursorValidityView); +::buffa::impl_view_reborrow!(CursorValidityView); +/** Self-contained, `'static` owned view of a `CursorValidity` message. + + Wraps [`::buffa::OwnedView`]`<`[`CursorValidityView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CursorValidityView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CursorValidityOwnedView(::buffa::OwnedView>); +impl CursorValidityOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorValidityOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorValidityOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CursorValidity, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CursorValidityOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CursorValidityView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CursorValidityView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CursorValidity { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Identifies the projection instance. A rebuild under a new generation makes + /// ordering values from the old one meaningless. + /// Mismatch: STALE_CURSOR_REASON_PROJECTION_REPLACED. + /// + /// Field 1: `projection_generation` + #[must_use] + pub fn projection_generation(&self) -> &'_ str { + self.0.reborrow().projection_generation + } + /// The projection position the scan is pinned to. Constant across every page + /// of one scan. + /// + /// A pinned scan requires the projection to still be able to answer as of this + /// point, which is what cursor expiry bounds. + /// + /// Field 2: `pinned_watermark` + #[must_use] + pub fn pinned_watermark(&self) -> u64 { + self.0.reborrow().pinned_watermark + } + /// Bumped whenever the set of effective events changes shape: rewind, which + /// retracts history the scan may already have passed, and compaction, which + /// replaces a span with a summary. Either leaves a cursor describing a prefix + /// that no longer exists. + /// + /// Mismatch is STALE_CURSOR_REASON_REWOUND or STALE_CURSOR_REASON_COMPACTED + /// depending on which change advanced it, so the server must know the cause of + /// an advance and not only that one happened. The distinction matters to a + /// caller: a compaction lost nothing, a rewind did. + /// + /// Field 3: `effective_history_revision` + #[must_use] + pub fn effective_history_revision(&self) -> u64 { + self.0.reborrow().effective_history_revision + } + /// Bumped by redaction and artifact erasure. Tracked separately from + /// effective_history_revision because it is the field that must be checked + /// even when nothing else moved: continuing to serve a scan cut before an + /// erasure would keep handing out content that was ordered destroyed. + /// Mismatch: STALE_CURSOR_REASON_PRIVACY_CHANGED. + /// + /// Field 4: `privacy_revision` + #[must_use] + pub fn privacy_revision(&self) -> u64 { + self.0.reborrow().privacy_revision + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CursorValidityOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CursorValidityOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CursorValidityOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CursorValidityOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CursorValidity { + type View<'a> = CursorValidityView<'a>; + type ViewHandle = CursorValidityOwnedView; +} +impl ::serde::Serialize for CursorValidityOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view_oneof.rs new file mode 100644 index 0000000000..bddb792bdf --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.__view_oneof.rs @@ -0,0 +1,20 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/page_cursor.proto + +pub mod page_cursor { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Scan<'a> { + History( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::HistoryScanCursorView<'a>, + >, + ), + SessionList( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::SessionListScanCursorView<'a>, + >, + ), + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.rs new file mode 100644 index 0000000000..1e2aade9ae --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.page_cursor.rs @@ -0,0 +1,1481 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/page_cursor.proto + +/// CursorEnvelope is what a `page_token` actually contains. +/// +/// These types are server-minted internals. They are published so the format is +/// reviewable and versioned, not so callers can read it: a client must treat a +/// token as opaque bytes and never construct, parse, or edit one. The server +/// owes nothing to a hand-built token beyond QUERY_ERROR_CODE_MALFORMED_CURSOR. +/// +/// The envelope keeps `payload` as bytes rather than an inline message on +/// purpose. `mac` authenticates the exact bytes the server emitted, and protobuf +/// serialization is not canonical, so a server that re-encoded a decoded message +/// to check the MAC could compute a different byte string than it signed. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CursorEnvelope { + /// Version of this envelope and payload format, independent of the query + /// ContractVersion. A token minted under an unknown format_version is + /// MALFORMED_CURSOR, not STALE_CURSOR: there is nothing to interpret. + /// + /// Field 1: `format_version` + #[serde( + rename = "formatVersion", + alias = "format_version", + with = "::buffa::json_helpers::uint32" + )] + pub format_version: u32, + /// Serialized PageCursor. + /// + /// Field 2: `payload` + #[serde(rename = "payload", with = "::buffa::json_helpers::bytes")] + pub payload: ::buffa::alloc::vec::Vec, + /// Authenticates format_version and payload under a server-held key. + /// + /// A cursor names a scan position, so an unauthenticated one is a request + /// parameter the caller controls. The MAC is what stops a caller from moving + /// the anchor, widening the selector, or pointing a scan at another session's + /// stream. It is tamper evidence and nothing more: a cursor is never + /// authorization, and every continuation is re-authorized from the caller's + /// own identity as if it were a fresh request. + /// + /// Field 3: `mac` + #[serde(rename = "mac", with = "::buffa::json_helpers::bytes")] + pub mac: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for CursorEnvelope { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CursorEnvelope") + .field("format_version", &self.format_version) + .field("payload", &self.payload) + .field("mac", &self.mac) + .finish() + } +} +impl CursorEnvelope { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorEnvelope"; +} +::buffa::impl_default_instance!(CursorEnvelope); +impl ::buffa::MessageName for CursorEnvelope { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CursorEnvelope"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CursorEnvelope"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorEnvelope"; +} +impl ::buffa::Message for CursorEnvelope { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.payload) as u64; + size += 1u64 + ::buffa::types::bytes_encoded_len(&self.mac) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.format_version, buf); + ::buffa::types::put_shared_bytes_field(2u32, &self.payload, buf); + ::buffa::types::put_shared_bytes_field(3u32, &self.mac, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.format_version = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes(&mut self.payload, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes(&mut self.mac, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.format_version = 0u32; + self.payload.clear(); + self.mac.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CursorEnvelope { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CURSOR_ENVELOPE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorEnvelope", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// PageCursor is the decoded scan position. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct PageCursor { + /// When the token stops being honored regardless of validity. + /// + /// A pinned scan holds read-model retention (see CursorValidity), so scans + /// cannot be allowed to live forever. Expiry is STALE_CURSOR with + /// STALE_CURSOR_REASON_EXPIRED, because restarting the scan is the fix. + /// + /// Field 3: `expires_at` + #[serde(rename = "expiresAt", alias = "expires_at")] + pub expires_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + #[serde(flatten)] + pub scan: ::core::option::Option<__buffa::oneof::page_cursor::Scan>, +} +impl ::core::fmt::Debug for PageCursor { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PageCursor") + .field("expires_at", &self.expires_at) + .field("scan", &self.scan) + .finish() + } +} +impl PageCursor { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PageCursor"; +} +::buffa::impl_default_instance!(PageCursor); +impl ::buffa::MessageName for PageCursor { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "PageCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.PageCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PageCursor"; +} +impl ::buffa::Message for PageCursor { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if let ::core::option::Option::Some(ref v) = self.scan { + match v { + __buffa::oneof::page_cursor::Scan::History(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::page_cursor::Scan::SessionList(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + if self.expires_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expires_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.scan { + match v { + __buffa::oneof::page_cursor::Scan::History(x) => { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::page_cursor::Scan::SessionList(x) => { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + if self.expires_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expires_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::page_cursor::Scan::History(ref mut existing), + ) = self.scan + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.scan = ::core::option::Option::Some( + __buffa::oneof::page_cursor::Scan::History( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::page_cursor::Scan::SessionList(ref mut existing), + ) = self.scan + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.scan = ::core::option::Option::Some( + __buffa::oneof::page_cursor::Scan::SessionList( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.expires_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.scan = ::core::option::Option::None; + self.expires_at = ::buffa::MessageField::none(); + } +} +impl<'de> serde::Deserialize<'de> for PageCursor { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = PageCursor; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct PageCursor") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __f_expires_at: ::core::option::Option< + ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + > = None; + let mut __oneof_scan: ::core::option::Option< + __buffa::oneof::page_cursor::Scan, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "expiresAt" | "expires_at" => { + __f_expires_at = Some( + map + .next_value::< + ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + >()?, + ); + } + "history" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + HistoryScanCursor, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_scan.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'scan'", + ), + ); + } + __oneof_scan = Some( + __buffa::oneof::page_cursor::Scan::History( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "sessionList" | "session_list" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + SessionListScanCursor, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_scan.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'scan'", + ), + ); + } + __oneof_scan = Some( + __buffa::oneof::page_cursor::Scan::SessionList( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + if let ::core::option::Option::Some(v) = __f_expires_at { + __r.expires_at = v; + } + __r.scan = __oneof_scan; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for PageCursor { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PAGE_CURSOR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PageCursor", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod page_cursor { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::__buffa::oneof::page_cursor::Scan; + #[doc(inline)] + pub use super::__buffa::view::oneof::page_cursor::Scan as ScanView; +} +/// HistoryScanCursor is a position within one session's history. +/// +/// This is the message that makes the paging guarantee true. History is +/// append-only and every item carries a SessionOrdinal that is assigned once and +/// never renumbered, so a position expressed as an ordinal keeps its meaning as +/// the session grows. A position expressed as an offset from either end does +/// not, which is why the count of items is deliberately absent here. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct HistoryScanCursor { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Contract the scan was opened at. The server keeps rendering at this version + /// for the life of the scan so a page is not shaped differently from its + /// predecessors. A continuation presenting a different major is + /// STALE_CURSOR_REASON_CONTRACT_CHANGED. + /// + /// Field 2: `minted_contract` + #[serde(rename = "mintedContract", alias = "minted_contract")] + pub minted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Fixed for the life of the scan. A continuation cannot reverse it; that is a + /// new scan. + /// + /// Field 3: `direction` + #[serde(rename = "direction", with = "::buffa::json_helpers::proto_enum")] + pub direction: ::buffa::EnumValue, + /// The effective-history head the scan was pinned to when it opened, as a + /// SessionOrdinal. + /// + /// The scan never looks past this, and that is what makes concurrent appends + /// harmless: a turn recorded after the scan opened is outside the window + /// rather than shifting rows inside it. A reverse scan walking toward older + /// history is unaffected by definition; a forward scan ends here even if newer + /// items exist by the time it arrives. + /// + /// Field 4: `anchor_ordinal` + #[serde( + rename = "anchorOrdinal", + alias = "anchor_ordinal", + with = "::buffa::json_helpers::uint64" + )] + pub anchor_ordinal: u64, + /// The last SessionOrdinal delivered. The next page resumes strictly past it + /// in `direction`, which is why an item can be neither repeated nor skipped: + /// the boundary is the identity of a delivered row, not a count of them. + /// + /// Field 5: `last_delivered_ordinal` + #[serde( + rename = "lastDeliveredOrdinal", + alias = "last_delivered_ordinal", + with = "::buffa::json_helpers::uint64" + )] + pub last_delivered_ordinal: u64, + /// Field 6: `validity` + #[serde(rename = "validity")] + pub validity: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for HistoryScanCursor { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HistoryScanCursor") + .field("session_id", &self.session_id) + .field("minted_contract", &self.minted_contract) + .field("direction", &self.direction) + .field("anchor_ordinal", &self.anchor_ordinal) + .field("last_delivered_ordinal", &self.last_delivered_ordinal) + .field("validity", &self.validity) + .finish() + } +} +impl HistoryScanCursor { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor"; +} +::buffa::impl_default_instance!(HistoryScanCursor); +impl ::buffa::MessageName for HistoryScanCursor { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "HistoryScanCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor"; +} +impl ::buffa::Message for HistoryScanCursor { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.minted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.direction.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.anchor_ordinal) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.last_delivered_ordinal) as u64; + if self.validity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.validity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.minted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minted_contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.direction.to_i32(), buf); + ::buffa::types::put_uint64_field(4u32, self.anchor_ordinal, buf); + ::buffa::types::put_uint64_field(5u32, self.last_delivered_ordinal, buf); + if self.validity.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.validity.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.minted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.direction = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.anchor_ordinal = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.last_delivered_ordinal = ::buffa::types::decode_uint64(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.validity.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.minted_contract = ::buffa::MessageField::none(); + self.direction = ::buffa::EnumValue::from(0); + self.anchor_ordinal = 0u64; + self.last_delivered_ordinal = 0u64; + self.validity = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for HistoryScanCursor { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HISTORY_SCAN_CURSOR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.HistoryScanCursor", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SessionListScanCursor is a position within a list scan. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionListScanCursor { + /// Field 1: `minted_contract` + #[serde(rename = "mintedContract", alias = "minted_contract")] + pub minted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Field 2: `selector` + #[serde(rename = "selector")] + pub selector: ::buffa::MessageField< + ListScanSelector, + ::buffa::Inline, + >, + /// Last row delivered. The next page resumes strictly after it in the scan's + /// ordering. + /// + /// Field 3: `last_delivered` + #[serde(rename = "lastDelivered", alias = "last_delivered")] + pub last_delivered: ::buffa::MessageField< + SessionOrderingKey, + ::buffa::Inline, + >, + /// Field 4: `validity` + #[serde(rename = "validity")] + pub validity: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for SessionListScanCursor { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionListScanCursor") + .field("minted_contract", &self.minted_contract) + .field("selector", &self.selector) + .field("last_delivered", &self.last_delivered) + .field("validity", &self.validity) + .finish() + } +} +impl SessionListScanCursor { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor"; +} +::buffa::impl_default_instance!(SessionListScanCursor); +impl ::buffa::MessageName for SessionListScanCursor { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionListScanCursor"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor"; +} +impl ::buffa::Message for SessionListScanCursor { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.minted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.minted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.selector.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.selector.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.last_delivered.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.last_delivered.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.validity.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.validity.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.minted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.minted_contract.write_to(__cache, buf); + } + if self.selector.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.selector.write_to(__cache, buf); + } + if self.last_delivered.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.last_delivered.write_to(__cache, buf); + } + if self.validity.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.validity.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.minted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.selector.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.last_delivered.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.validity.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.minted_contract = ::buffa::MessageField::none(); + self.selector = ::buffa::MessageField::none(); + self.last_delivered = ::buffa::MessageField::none(); + self.validity = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionListScanCursor { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_LIST_SCAN_CURSOR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionListScanCursor", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ListScanSelector is the request shape the scan was opened with. +/// +/// A continuation whose request disagrees with this is MALFORMED_CURSOR rather +/// than a silently re-scoped scan. Changing the scope, workspace, or archived +/// filter mid-scan produces a page sequence that is neither the old selection +/// nor the new one, and the caller has no way to notice. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListScanSelector { + /// Field 1: `scope` + #[serde(rename = "scope", with = "::buffa::json_helpers::proto_enum")] + pub scope: ::buffa::EnumValue, + /// Field 2: `workspace_id` + #[serde( + rename = "workspaceId", + alias = "workspace_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub workspace_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 3: `archived` + #[serde(rename = "archived", with = "::buffa::json_helpers::proto_enum")] + pub archived: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for ListScanSelector { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListScanSelector") + .field("scope", &self.scope) + .field("workspace_id", &self.workspace_id) + .field("archived", &self.archived) + .finish() + } +} +impl ListScanSelector { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListScanSelector"; +} +impl ListScanSelector { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::workspace_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_workspace_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.workspace_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ListScanSelector); +impl ::buffa::MessageName for ListScanSelector { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ListScanSelector"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ListScanSelector"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListScanSelector"; +} +impl ::buffa::Message for ListScanSelector { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.scope.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.workspace_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.archived.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.scope.to_i32(), buf); + if let Some(ref v) = self.workspace_id { + ::buffa::types::put_string_field(2u32, v, buf); + } + ::buffa::types::put_int32_field(3u32, self.archived.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.scope = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .workspace_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.archived = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.scope = ::buffa::EnumValue::from(0); + self.workspace_id = ::core::option::Option::None; + self.archived = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListScanSelector { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_SCAN_SELECTOR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ListScanSelector", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SessionOrderingKey is one row's position in the list ordering. +/// +/// Ordering is by `ordering_value` descending, then `session_id` ascending. The +/// tie-breaker is not decoration: ordering values collide, and a boundary that +/// cannot distinguish two rows sharing one must either re-emit both or drop +/// both. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionOrderingKey { + /// The row's ordering value as of the scan's pinned watermark, not as of now. + /// + /// Recency ordering is the thing a session picker wants and is also mutable, a + /// combination that breaks naive pagination: a row that gains activity after + /// the cursor has passed its old position jumps ahead of the cursor and is + /// never delivered. Reading the ordering as of a fixed watermark is what + /// removes that skip, and it is an obligation on the list projection rather + /// than something this contract can assert by itself. + /// + /// Field 1: `ordering_value` + #[serde( + rename = "orderingValue", + alias = "ordering_value", + with = "::buffa::json_helpers::uint64" + )] + pub ordering_value: u64, + /// Field 2: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for SessionOrderingKey { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionOrderingKey") + .field("ordering_value", &self.ordering_value) + .field("session_id", &self.session_id) + .finish() + } +} +impl SessionOrderingKey { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey"; +} +::buffa::impl_default_instance!(SessionOrderingKey); +impl ::buffa::MessageName for SessionOrderingKey { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionOrderingKey"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey"; +} +impl ::buffa::Message for SessionOrderingKey { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordering_value) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.ordering_value, buf); + ::buffa::types::put_string_field(2u32, &self.session_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordering_value = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ordering_value = 0u64; + self.session_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionOrderingKey { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_ORDERING_KEY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionOrderingKey", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// CursorValidity is everything a cursor binds to besides its position. +/// +/// Each field answers one question: is the sequence this cursor was cut from +/// still the same sequence? A change in any of them means resuming would produce +/// a page sequence that never existed as a whole, so the server refuses with +/// QUERY_ERROR_CODE_STALE_CURSOR and the matching StaleCursorReason instead of +/// serving a plausible page. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CursorValidity { + /// Identifies the projection instance. A rebuild under a new generation makes + /// ordering values from the old one meaningless. + /// Mismatch: STALE_CURSOR_REASON_PROJECTION_REPLACED. + /// + /// Field 1: `projection_generation` + #[serde( + rename = "projectionGeneration", + alias = "projection_generation", + with = "::buffa::json_helpers::proto_string" + )] + pub projection_generation: ::buffa::alloc::string::String, + /// The projection position the scan is pinned to. Constant across every page + /// of one scan. + /// + /// A pinned scan requires the projection to still be able to answer as of this + /// point, which is what cursor expiry bounds. + /// + /// Field 2: `pinned_watermark` + #[serde( + rename = "pinnedWatermark", + alias = "pinned_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub pinned_watermark: u64, + /// Bumped whenever the set of effective events changes shape: rewind, which + /// retracts history the scan may already have passed, and compaction, which + /// replaces a span with a summary. Either leaves a cursor describing a prefix + /// that no longer exists. + /// + /// Mismatch is STALE_CURSOR_REASON_REWOUND or STALE_CURSOR_REASON_COMPACTED + /// depending on which change advanced it, so the server must know the cause of + /// an advance and not only that one happened. The distinction matters to a + /// caller: a compaction lost nothing, a rewind did. + /// + /// Field 3: `effective_history_revision` + #[serde( + rename = "effectiveHistoryRevision", + alias = "effective_history_revision", + with = "::buffa::json_helpers::uint64" + )] + pub effective_history_revision: u64, + /// Bumped by redaction and artifact erasure. Tracked separately from + /// effective_history_revision because it is the field that must be checked + /// even when nothing else moved: continuing to serve a scan cut before an + /// erasure would keep handing out content that was ordered destroyed. + /// Mismatch: STALE_CURSOR_REASON_PRIVACY_CHANGED. + /// + /// Field 4: `privacy_revision` + #[serde( + rename = "privacyRevision", + alias = "privacy_revision", + with = "::buffa::json_helpers::uint64" + )] + pub privacy_revision: u64, +} +impl ::core::fmt::Debug for CursorValidity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CursorValidity") + .field("projection_generation", &self.projection_generation) + .field("pinned_watermark", &self.pinned_watermark) + .field("effective_history_revision", &self.effective_history_revision) + .field("privacy_revision", &self.privacy_revision) + .finish() + } +} +impl CursorValidity { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorValidity"; +} +::buffa::impl_default_instance!(CursorValidity); +impl ::buffa::MessageName for CursorValidity { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CursorValidity"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CursorValidity"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorValidity"; +} +impl ::buffa::Message for CursorValidity { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.pinned_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.effective_history_revision) + as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.privacy_revision) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(2u32, self.pinned_watermark, buf); + ::buffa::types::put_uint64_field(3u32, self.effective_history_revision, buf); + ::buffa::types::put_uint64_field(4u32, self.privacy_revision, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.projection_generation, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.pinned_watermark = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.effective_history_revision = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.privacy_revision = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.projection_generation.clear(); + self.pinned_watermark = 0u64; + self.effective_history_revision = 0u64; + self.privacy_revision = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CursorValidity { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CURSOR_VALIDITY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CursorValidity", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.__view.rs new file mode 100644 index 0000000000..a02fdc0b21 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.__view.rs @@ -0,0 +1,1484 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto + +/// PresentationCacheBinding is the projection state a client-side cache was +/// rendered against. +/// +/// A client that reopens a session wants to paint the timeline before the first +/// query returns. The cached copy is only safe to paint if the projection it +/// came from still exists and still says the same things. This message is what +/// the cache stores alongside its rendered content so that question has an +/// answer other than a guess about elapsed time. +/// +/// The four projection coordinates are the same four a page cursor pins in +/// `CursorValidity`, because the events that invalidate a cursor and the events +/// that invalidate a cache are the same events. They are separate messages +/// rather than one shared one because they are checked by different parties: a +/// cursor is minted by the server, opaque to the client, and validated by the +/// server on the next page; a binding is held by the client, readable by the +/// client, and checked before anything is painted. Sharing the type would make +/// a change made for one validator's benefit land on the other's. +/// +/// Nothing here describes the rendering itself. Terminal width, scroll position, +/// theme, and ANSI handling are the client's state and stay in the client: the +/// Session event log records what happened, not what a viewer looked like while +/// watching it, and a projection that stored presentation state would be one +/// that has to be rebuilt every time a renderer changes. +#[derive(Clone, Debug, Default)] +pub struct PresentationCacheBindingView<'a> { + /// The projection instance that produced the cached content. A projection + /// rebuild mints a new generation, and content from the old one is not a + /// stale version of the new one, it is output from a different computation. + /// + /// Field 1: `projection_generation` + pub projection_generation: &'a str, + /// Stream position the projection had applied through when it rendered this. + /// + /// Field 2: `processed_watermark` + pub processed_watermark: u64, + /// Revision of the session's effective history, bumped by rewind and by + /// compaction. + /// + /// This is the field that makes "my cache is just older" checkable rather than + /// assumed. A cache at a lower watermark is a safe prefix of the current view + /// only when history is append-only between the two positions. Rewind and + /// compaction retract content that was there, so after either one a lower + /// watermark is not a prefix of a higher one and the cache is wrong rather + /// than incomplete. + /// + /// Field 3: `effective_history_revision` + pub effective_history_revision: u64, + /// Revision of the session's privacy state, bumped by redaction and by + /// artifact erasure. + /// + /// Tracked apart from history because it is the one that must be checked even + /// when nothing else moved, and because getting it wrong is not a staleness + /// annoyance. A cache painted after a redaction shows content someone + /// deliberately destroyed, on a screen, to a person, which is the failure the + /// redaction was performed to prevent. + /// + /// Field 4: `privacy_revision` + pub privacy_revision: u64, + /// Query contract version the cached content was rendered at. A cache built + /// from a response the current contract would render differently is not + /// reusable even when every projection coordinate still matches. + /// + /// Field 5: `contract_version` + pub contract_version: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Opaque identifier for the client-side rendering code that produced the + /// cached content. + /// + /// The server never interprets it and never compares it. It is carried so a + /// client that ships a new renderer can discard its own caches without the + /// server having to know anything about renderers, which is the arrangement + /// that keeps rendering changes from being a server deployment. + /// + /// Field 6: `renderer_version` + pub renderer_version: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> PresentationCacheBindingView<'a> { + /**Whether required field `projection_generation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projection_generation(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `processed_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_processed_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `effective_history_revision` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_effective_history_revision(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `privacy_revision` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_privacy_revision(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `contract_version` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract_version(&self) -> bool { + self.contract_version.is_set() + } + /**Whether required field `renderer_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_renderer_version(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for PresentationCacheBindingView<'a> { + type Owned = super::super::PresentationCacheBinding; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.projection_generation = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.processed_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.effective_history_revision = ::buffa::types::decode_uint64( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.privacy_revision = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract_version.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract_version = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.renderer_version = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::PresentationCacheBinding, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::PresentationCacheBinding, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::PresentationCacheBinding { + projection_generation: self.projection_generation.to_string(), + processed_watermark: self.processed_watermark, + effective_history_revision: self.effective_history_revision, + privacy_revision: self.privacy_revision, + contract_version: match self.contract_version.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + renderer_version: self.renderer_version.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for PresentationCacheBindingView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.effective_history_revision) + as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.privacy_revision) as u64; + if self.contract_version.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract_version.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.renderer_version) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(2u32, self.processed_watermark, buf); + ::buffa::types::put_uint64_field(3u32, self.effective_history_revision, buf); + ::buffa::types::put_uint64_field(4u32, self.privacy_revision, buf); + if self.contract_version.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract_version.write_to(__cache, buf); + } + ::buffa::types::put_string_field(6u32, &self.renderer_version, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for PresentationCacheBindingView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("projectionGeneration", self.projection_generation)?; + } + { + __map + .serialize_entry( + "processedWatermark", + &::buffa::json_helpers::ProtoJson(&self.processed_watermark), + )?; + } + { + __map + .serialize_entry( + "effectiveHistoryRevision", + &::buffa::json_helpers::ProtoJson(&self.effective_history_revision), + )?; + } + { + __map + .serialize_entry( + "privacyRevision", + &::buffa::json_helpers::ProtoJson(&self.privacy_revision), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.contract_version.as_option() + { + __map.serialize_entry("contractVersion", __v)?; + } + } + { + __map.serialize_entry("rendererVersion", self.renderer_version)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for PresentationCacheBindingView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "PresentationCacheBinding"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding"; +} +::buffa::impl_default_view_instance!(PresentationCacheBindingView); +::buffa::impl_view_reborrow!(PresentationCacheBindingView); +/** Self-contained, `'static` owned view of a `PresentationCacheBinding` message. + + Wraps [`::buffa::OwnedView`]`<`[`PresentationCacheBindingView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`PresentationCacheBindingView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct PresentationCacheBindingOwnedView( + ::buffa::OwnedView>, +); +impl PresentationCacheBindingOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PresentationCacheBindingOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PresentationCacheBindingOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::PresentationCacheBinding, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + PresentationCacheBindingOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`PresentationCacheBindingView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &PresentationCacheBindingView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::PresentationCacheBinding { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The projection instance that produced the cached content. A projection + /// rebuild mints a new generation, and content from the old one is not a + /// stale version of the new one, it is output from a different computation. + /// + /// Field 1: `projection_generation` + #[must_use] + pub fn projection_generation(&self) -> &'_ str { + self.0.reborrow().projection_generation + } + /// Stream position the projection had applied through when it rendered this. + /// + /// Field 2: `processed_watermark` + #[must_use] + pub fn processed_watermark(&self) -> u64 { + self.0.reborrow().processed_watermark + } + /// Revision of the session's effective history, bumped by rewind and by + /// compaction. + /// + /// This is the field that makes "my cache is just older" checkable rather than + /// assumed. A cache at a lower watermark is a safe prefix of the current view + /// only when history is append-only between the two positions. Rewind and + /// compaction retract content that was there, so after either one a lower + /// watermark is not a prefix of a higher one and the cache is wrong rather + /// than incomplete. + /// + /// Field 3: `effective_history_revision` + #[must_use] + pub fn effective_history_revision(&self) -> u64 { + self.0.reborrow().effective_history_revision + } + /// Revision of the session's privacy state, bumped by redaction and by + /// artifact erasure. + /// + /// Tracked apart from history because it is the one that must be checked even + /// when nothing else moved, and because getting it wrong is not a staleness + /// annoyance. A cache painted after a redaction shows content someone + /// deliberately destroyed, on a screen, to a person, which is the failure the + /// redaction was performed to prevent. + /// + /// Field 4: `privacy_revision` + #[must_use] + pub fn privacy_revision(&self) -> u64 { + self.0.reborrow().privacy_revision + } + /// Query contract version the cached content was rendered at. A cache built + /// from a response the current contract would render differently is not + /// reusable even when every projection coordinate still matches. + /// + /// Field 5: `contract_version` + #[must_use] + pub fn contract_version( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().contract_version + } + /// Opaque identifier for the client-side rendering code that produced the + /// cached content. + /// + /// The server never interprets it and never compares it. It is carried so a + /// client that ships a new renderer can discard its own caches without the + /// server having to know anything about renderers, which is the arrangement + /// that keeps rendering changes from being a server deployment. + /// + /// Field 6: `renderer_version` + #[must_use] + pub fn renderer_version(&self) -> &'_ str { + self.0.reborrow().renderer_version + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for PresentationCacheBindingOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + PresentationCacheBindingOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: PresentationCacheBindingOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for PresentationCacheBindingOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::PresentationCacheBinding { + type View<'a> = PresentationCacheBindingView<'a>; + type ViewHandle = PresentationCacheBindingOwnedView; +} +impl ::serde::Serialize for PresentationCacheBindingOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// CheckPresentationCacheRequest asks whether a held cache may still be shown. +/// +/// It is deliberately not a read. A caller that wanted the content would call +/// GetSessionHistory; this exists for the caller that already has content and +/// needs a verdict cheaper than fetching it again. There is no field here that +/// could make it return timeline data, so it cannot quietly become the +/// expensive path it was added to avoid. +#[derive(Clone, Debug, Default)] +pub struct CheckPresentationCacheRequestView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `accepted_contract` + pub accepted_contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// What the held cache was rendered against. + /// + /// Field 3: `binding` + pub binding: ::buffa::MessageFieldView< + super::super::__buffa::view::PresentationCacheBindingView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CheckPresentationCacheRequestView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `accepted_contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_accepted_contract(&self) -> bool { + self.accepted_contract.is_set() + } + /**Whether required field `binding` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_binding(&self) -> bool { + self.binding.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CheckPresentationCacheRequestView<'a> { + type Owned = super::super::CheckPresentationCacheRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.accepted_contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.accepted_contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.binding.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.binding = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::CheckPresentationCacheRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::CheckPresentationCacheRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CheckPresentationCacheRequest { + session_id: self.session_id.to_string(), + accepted_contract: match self.accepted_contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + binding: match self.binding.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::PresentationCacheBinding, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CheckPresentationCacheRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.binding.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.binding.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + if self.binding.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.binding.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CheckPresentationCacheRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.accepted_contract.as_option() + { + __map.serialize_entry("acceptedContract", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.binding.as_option() { + __map.serialize_entry("binding", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CheckPresentationCacheRequestView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CheckPresentationCacheRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest"; +} +::buffa::impl_default_view_instance!(CheckPresentationCacheRequestView); +::buffa::impl_view_reborrow!(CheckPresentationCacheRequestView); +/** Self-contained, `'static` owned view of a `CheckPresentationCacheRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`CheckPresentationCacheRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CheckPresentationCacheRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CheckPresentationCacheRequestOwnedView( + ::buffa::OwnedView>, +); +impl CheckPresentationCacheRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CheckPresentationCacheRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CheckPresentationCacheRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CheckPresentationCacheRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CheckPresentationCacheRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `accepted_contract` + #[must_use] + pub fn accepted_contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().accepted_contract + } + /// What the held cache was rendered against. + /// + /// Field 3: `binding` + #[must_use] + pub fn binding( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::PresentationCacheBindingView<'_>, + > { + &self.0.reborrow().binding + } +} +impl ::core::convert::From< + ::buffa::OwnedView>, +> for CheckPresentationCacheRequestOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + CheckPresentationCacheRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CheckPresentationCacheRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef< + ::buffa::OwnedView>, +> for CheckPresentationCacheRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CheckPresentationCacheRequest { + type View<'a> = CheckPresentationCacheRequestView<'a>; + type ViewHandle = CheckPresentationCacheRequestOwnedView; +} +impl ::serde::Serialize for CheckPresentationCacheRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// CheckPresentationCacheResponse is the verdict on a held cache. +#[derive(Clone, Debug, Default)] +pub struct CheckPresentationCacheResponseView<'a> { + /// Field 1: `contract` + pub contract: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'a>, + >, + /// Field 2: `usability` + pub usability: ::buffa::EnumValue, + /// What a cache rendered now would be bound to. + /// + /// Present on every verdict, including a discard, so a client that is about to + /// refetch knows what to bind the replacement to without a second round trip. + /// + /// Field 3: `current` + pub current: ::buffa::MessageFieldView< + super::super::__buffa::view::PresentationCacheBindingView<'a>, + >, + /// How current the projection that answered was. A usable verdict from a + /// lagging projection is a verdict about a lagging view, and the caller is + /// owed that distinction. + /// + /// Field 4: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CheckPresentationCacheResponseView<'a> { + /**Whether required field `contract` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_contract(&self) -> bool { + self.contract.is_set() + } + /**Whether required field `usability` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_usability(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `current` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_current(&self) -> bool { + self.current.is_set() + } + /**Whether required field `freshness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_freshness(&self) -> bool { + self.freshness.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CheckPresentationCacheResponseView<'a> { + type Owned = super::super::CheckPresentationCacheResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.contract.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.contract = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.usability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.current.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.current = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::CheckPresentationCacheResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::CheckPresentationCacheResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CheckPresentationCacheResponse { + contract: match self.contract.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractNegotiation, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + usability: self.usability, + current: match self.current.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::PresentationCacheBinding, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CheckPresentationCacheResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.usability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.current.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.current.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.usability.to_i32(), buf); + if self.current.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.current.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CheckPresentationCacheResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.contract.as_option() { + __map.serialize_entry("contract", __v)?; + } + } + { + __map.serialize_entry("usability", &self.usability)?; + } + { + if let ::core::option::Option::Some(__v) = self.current.as_option() { + __map.serialize_entry("current", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CheckPresentationCacheResponseView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CheckPresentationCacheResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse"; +} +::buffa::impl_default_view_instance!(CheckPresentationCacheResponseView); +::buffa::impl_view_reborrow!(CheckPresentationCacheResponseView); +/** Self-contained, `'static` owned view of a `CheckPresentationCacheResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`CheckPresentationCacheResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CheckPresentationCacheResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CheckPresentationCacheResponseOwnedView( + ::buffa::OwnedView>, +); +impl CheckPresentationCacheResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CheckPresentationCacheResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckPresentationCacheResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CheckPresentationCacheResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CheckPresentationCacheResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CheckPresentationCacheResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `contract` + #[must_use] + pub fn contract( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractNegotiationView<'_>, + > { + &self.0.reborrow().contract + } + /// Field 2: `usability` + #[must_use] + pub fn usability(&self) -> ::buffa::EnumValue { + self.0.reborrow().usability + } + /// What a cache rendered now would be bound to. + /// + /// Present on every verdict, including a discard, so a client that is about to + /// refetch knows what to bind the replacement to without a second round trip. + /// + /// Field 3: `current` + #[must_use] + pub fn current( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::PresentationCacheBindingView<'_>, + > { + &self.0.reborrow().current + } + /// How current the projection that answered was. A usable verdict from a + /// lagging projection is a verdict about a lagging view, and the caller is + /// owed that distinction. + /// + /// Field 4: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } +} +impl ::core::convert::From< + ::buffa::OwnedView>, +> for CheckPresentationCacheResponseOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + CheckPresentationCacheResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CheckPresentationCacheResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef< + ::buffa::OwnedView>, +> for CheckPresentationCacheResponseOwnedView { + fn as_ref( + &self, + ) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CheckPresentationCacheResponse { + type View<'a> = CheckPresentationCacheResponseView<'a>; + type ViewHandle = CheckPresentationCacheResponseOwnedView; +} +impl ::serde::Serialize for CheckPresentationCacheResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.rs new file mode 100644 index 0000000000..96d2962430 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.presentation_cache.rs @@ -0,0 +1,913 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/presentation_cache.proto + +/// CacheUsability is what a client may do with the cache it holds. +/// +/// The values are ordered by how much of the cache survives, and the zero value +/// is the one that discards, so a client that reads a variant it does not know +/// falls back to fetching rather than to painting. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum CacheUsability { + /// Unknown verdict. Treat as DISCARD. + CACHE_USABILITY_UNSPECIFIED = 0i32, + /// Every coordinate matches. The cache is the current view and may be painted + /// as final. + CACHE_USABILITY_CURRENT = 1i32, + /// The cache is a strict prefix: same generation, same history revision, same + /// privacy revision, lower watermark. + /// + /// It may be painted immediately and then extended by reading forward from + /// `binding.processed_watermark`. This is the only variant that lets a client + /// show something before its first query returns, and it is gated on the + /// revisions rather than on the watermark, because a lower watermark alone + /// does not establish that the interval between them only added. + CACHE_USABILITY_APPENDABLE = 2i32, + /// Content the cache holds no longer exists, because a rewind, a compaction, a + /// redaction, or an artifact erasure removed it. + /// + /// Distinct from REPLACED because the projection is fine; the history changed + /// underneath it. Distinct from STALE because there is no safe subset: the + /// client cannot know which of its rows were the retracted ones, so it + /// discards all of them. + CACHE_USABILITY_RETRACTED = 3i32, + /// The projection generation differs. The cache came from a computation that + /// no longer runs, so it is not old output, it is foreign output. + CACHE_USABILITY_REPLACED = 4i32, + /// The contract major or the renderer version differs from what a fresh render + /// would use. The content may still be accurate and is still not reusable. + CACHE_USABILITY_INCOMPATIBLE = 5i32, + /// The server could not decide, because its own projection state is unknown to + /// it. Reported rather than resolved to DISCARD so a client can tell a cache + /// that was rejected from a cache that was never judged, and so a degraded + /// server does not silently trigger a refetch storm it cannot serve. + CACHE_USABILITY_INDETERMINATE = 6i32, +} +impl CacheUsability { + ///Idiomatic alias for [`Self::CACHE_USABILITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CACHE_USABILITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::CACHE_USABILITY_CURRENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Current: Self = Self::CACHE_USABILITY_CURRENT; + ///Idiomatic alias for [`Self::CACHE_USABILITY_APPENDABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Appendable: Self = Self::CACHE_USABILITY_APPENDABLE; + ///Idiomatic alias for [`Self::CACHE_USABILITY_RETRACTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Retracted: Self = Self::CACHE_USABILITY_RETRACTED; + ///Idiomatic alias for [`Self::CACHE_USABILITY_REPLACED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Replaced: Self = Self::CACHE_USABILITY_REPLACED; + ///Idiomatic alias for [`Self::CACHE_USABILITY_INCOMPATIBLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Incompatible: Self = Self::CACHE_USABILITY_INCOMPATIBLE; + ///Idiomatic alias for [`Self::CACHE_USABILITY_INDETERMINATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Indeterminate: Self = Self::CACHE_USABILITY_INDETERMINATE; +} +impl ::core::default::Default for CacheUsability { + fn default() -> Self { + Self::CACHE_USABILITY_UNSPECIFIED + } +} +impl ::serde::Serialize for CacheUsability { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for CacheUsability { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = CacheUsability; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(CacheUsability) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for CacheUsability { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for CacheUsability { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_CURRENT), + 2i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_APPENDABLE), + 3i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_RETRACTED), + 4i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_REPLACED), + 5i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_INCOMPATIBLE), + 6i32 => ::core::option::Option::Some(Self::CACHE_USABILITY_INDETERMINATE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CACHE_USABILITY_UNSPECIFIED => "CACHE_USABILITY_UNSPECIFIED", + Self::CACHE_USABILITY_CURRENT => "CACHE_USABILITY_CURRENT", + Self::CACHE_USABILITY_APPENDABLE => "CACHE_USABILITY_APPENDABLE", + Self::CACHE_USABILITY_RETRACTED => "CACHE_USABILITY_RETRACTED", + Self::CACHE_USABILITY_REPLACED => "CACHE_USABILITY_REPLACED", + Self::CACHE_USABILITY_INCOMPATIBLE => "CACHE_USABILITY_INCOMPATIBLE", + Self::CACHE_USABILITY_INDETERMINATE => "CACHE_USABILITY_INDETERMINATE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CACHE_USABILITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_UNSPECIFIED) + } + "CACHE_USABILITY_CURRENT" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_CURRENT) + } + "CACHE_USABILITY_APPENDABLE" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_APPENDABLE) + } + "CACHE_USABILITY_RETRACTED" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_RETRACTED) + } + "CACHE_USABILITY_REPLACED" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_REPLACED) + } + "CACHE_USABILITY_INCOMPATIBLE" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_INCOMPATIBLE) + } + "CACHE_USABILITY_INDETERMINATE" => { + ::core::option::Option::Some(Self::CACHE_USABILITY_INDETERMINATE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CACHE_USABILITY_UNSPECIFIED, + Self::CACHE_USABILITY_CURRENT, + Self::CACHE_USABILITY_APPENDABLE, + Self::CACHE_USABILITY_RETRACTED, + Self::CACHE_USABILITY_REPLACED, + Self::CACHE_USABILITY_INCOMPATIBLE, + Self::CACHE_USABILITY_INDETERMINATE, + ] + } +} +/// PresentationCacheBinding is the projection state a client-side cache was +/// rendered against. +/// +/// A client that reopens a session wants to paint the timeline before the first +/// query returns. The cached copy is only safe to paint if the projection it +/// came from still exists and still says the same things. This message is what +/// the cache stores alongside its rendered content so that question has an +/// answer other than a guess about elapsed time. +/// +/// The four projection coordinates are the same four a page cursor pins in +/// `CursorValidity`, because the events that invalidate a cursor and the events +/// that invalidate a cache are the same events. They are separate messages +/// rather than one shared one because they are checked by different parties: a +/// cursor is minted by the server, opaque to the client, and validated by the +/// server on the next page; a binding is held by the client, readable by the +/// client, and checked before anything is painted. Sharing the type would make +/// a change made for one validator's benefit land on the other's. +/// +/// Nothing here describes the rendering itself. Terminal width, scroll position, +/// theme, and ANSI handling are the client's state and stay in the client: the +/// Session event log records what happened, not what a viewer looked like while +/// watching it, and a projection that stored presentation state would be one +/// that has to be rebuilt every time a renderer changes. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct PresentationCacheBinding { + /// The projection instance that produced the cached content. A projection + /// rebuild mints a new generation, and content from the old one is not a + /// stale version of the new one, it is output from a different computation. + /// + /// Field 1: `projection_generation` + #[serde( + rename = "projectionGeneration", + alias = "projection_generation", + with = "::buffa::json_helpers::proto_string" + )] + pub projection_generation: ::buffa::alloc::string::String, + /// Stream position the projection had applied through when it rendered this. + /// + /// Field 2: `processed_watermark` + #[serde( + rename = "processedWatermark", + alias = "processed_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub processed_watermark: u64, + /// Revision of the session's effective history, bumped by rewind and by + /// compaction. + /// + /// This is the field that makes "my cache is just older" checkable rather than + /// assumed. A cache at a lower watermark is a safe prefix of the current view + /// only when history is append-only between the two positions. Rewind and + /// compaction retract content that was there, so after either one a lower + /// watermark is not a prefix of a higher one and the cache is wrong rather + /// than incomplete. + /// + /// Field 3: `effective_history_revision` + #[serde( + rename = "effectiveHistoryRevision", + alias = "effective_history_revision", + with = "::buffa::json_helpers::uint64" + )] + pub effective_history_revision: u64, + /// Revision of the session's privacy state, bumped by redaction and by + /// artifact erasure. + /// + /// Tracked apart from history because it is the one that must be checked even + /// when nothing else moved, and because getting it wrong is not a staleness + /// annoyance. A cache painted after a redaction shows content someone + /// deliberately destroyed, on a screen, to a person, which is the failure the + /// redaction was performed to prevent. + /// + /// Field 4: `privacy_revision` + #[serde( + rename = "privacyRevision", + alias = "privacy_revision", + with = "::buffa::json_helpers::uint64" + )] + pub privacy_revision: u64, + /// Query contract version the cached content was rendered at. A cache built + /// from a response the current contract would render differently is not + /// reusable even when every projection coordinate still matches. + /// + /// Field 5: `contract_version` + #[serde(rename = "contractVersion", alias = "contract_version")] + pub contract_version: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Opaque identifier for the client-side rendering code that produced the + /// cached content. + /// + /// The server never interprets it and never compares it. It is carried so a + /// client that ships a new renderer can discard its own caches without the + /// server having to know anything about renderers, which is the arrangement + /// that keeps rendering changes from being a server deployment. + /// + /// Field 6: `renderer_version` + #[serde( + rename = "rendererVersion", + alias = "renderer_version", + with = "::buffa::json_helpers::proto_string" + )] + pub renderer_version: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for PresentationCacheBinding { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PresentationCacheBinding") + .field("projection_generation", &self.projection_generation) + .field("processed_watermark", &self.processed_watermark) + .field("effective_history_revision", &self.effective_history_revision) + .field("privacy_revision", &self.privacy_revision) + .field("contract_version", &self.contract_version) + .field("renderer_version", &self.renderer_version) + .finish() + } +} +impl PresentationCacheBinding { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding"; +} +::buffa::impl_default_instance!(PresentationCacheBinding); +impl ::buffa::MessageName for PresentationCacheBinding { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "PresentationCacheBinding"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding"; +} +impl ::buffa::Message for PresentationCacheBinding { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.effective_history_revision) + as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.privacy_revision) as u64; + if self.contract_version.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract_version.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.renderer_version) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(2u32, self.processed_watermark, buf); + ::buffa::types::put_uint64_field(3u32, self.effective_history_revision, buf); + ::buffa::types::put_uint64_field(4u32, self.privacy_revision, buf); + if self.contract_version.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract_version.write_to(__cache, buf); + } + ::buffa::types::put_string_field(6u32, &self.renderer_version, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.projection_generation, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.processed_watermark = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.effective_history_revision = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.privacy_revision = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract_version.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.renderer_version, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.projection_generation.clear(); + self.processed_watermark = 0u64; + self.effective_history_revision = 0u64; + self.privacy_revision = 0u64; + self.contract_version = ::buffa::MessageField::none(); + self.renderer_version.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for PresentationCacheBinding { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PRESENTATION_CACHE_BINDING_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.PresentationCacheBinding", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// CheckPresentationCacheRequest asks whether a held cache may still be shown. +/// +/// It is deliberately not a read. A caller that wanted the content would call +/// GetSessionHistory; this exists for the caller that already has content and +/// needs a verdict cheaper than fetching it again. There is no field here that +/// could make it return timeline data, so it cannot quietly become the +/// expensive path it was added to avoid. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CheckPresentationCacheRequest { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `accepted_contract` + #[serde(rename = "acceptedContract", alias = "accepted_contract")] + pub accepted_contract: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// What the held cache was rendered against. + /// + /// Field 3: `binding` + #[serde(rename = "binding")] + pub binding: ::buffa::MessageField< + PresentationCacheBinding, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for CheckPresentationCacheRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CheckPresentationCacheRequest") + .field("session_id", &self.session_id) + .field("accepted_contract", &self.accepted_contract) + .field("binding", &self.binding) + .finish() + } +} +impl CheckPresentationCacheRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest"; +} +::buffa::impl_default_instance!(CheckPresentationCacheRequest); +impl ::buffa::MessageName for CheckPresentationCacheRequest { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CheckPresentationCacheRequest"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest"; +} +impl ::buffa::Message for CheckPresentationCacheRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.accepted_contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.accepted_contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.binding.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.binding.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.accepted_contract.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.accepted_contract.write_to(__cache, buf); + } + if self.binding.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.binding.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.accepted_contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.binding.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.accepted_contract = ::buffa::MessageField::none(); + self.binding = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckPresentationCacheRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CHECK_PRESENTATION_CACHE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// CheckPresentationCacheResponse is the verdict on a held cache. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CheckPresentationCacheResponse { + /// Field 1: `contract` + #[serde(rename = "contract")] + pub contract: ::buffa::MessageField< + ContractNegotiation, + ::buffa::Inline, + >, + /// Field 2: `usability` + #[serde(rename = "usability", with = "::buffa::json_helpers::proto_enum")] + pub usability: ::buffa::EnumValue, + /// What a cache rendered now would be bound to. + /// + /// Present on every verdict, including a discard, so a client that is about to + /// refetch knows what to bind the replacement to without a second round trip. + /// + /// Field 3: `current` + #[serde(rename = "current")] + pub current: ::buffa::MessageField< + PresentationCacheBinding, + ::buffa::Inline, + >, + /// How current the projection that answered was. A usable verdict from a + /// lagging projection is a verdict about a lagging view, and the caller is + /// owed that distinction. + /// + /// Field 4: `freshness` + #[serde(rename = "freshness")] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for CheckPresentationCacheResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CheckPresentationCacheResponse") + .field("contract", &self.contract) + .field("usability", &self.usability) + .field("current", &self.current) + .field("freshness", &self.freshness) + .finish() + } +} +impl CheckPresentationCacheResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse"; +} +::buffa::impl_default_instance!(CheckPresentationCacheResponse); +impl ::buffa::MessageName for CheckPresentationCacheResponse { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "CheckPresentationCacheResponse"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse"; +} +impl ::buffa::Message for CheckPresentationCacheResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.contract.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.contract.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.usability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.current.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.current.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.contract.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.contract.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(2u32, self.usability.to_i32(), buf); + if self.current.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.current.write_to(__cache, buf); + } + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.contract.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.usability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.current.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.contract = ::buffa::MessageField::none(); + self.usability = ::buffa::EnumValue::from(0); + self.current = ::buffa::MessageField::none(); + self.freshness = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckPresentationCacheResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CHECK_PRESENTATION_CACHE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.CheckPresentationCacheResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.__view.rs new file mode 100644 index 0000000000..e1f973c55e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.__view.rs @@ -0,0 +1,953 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto + +/// ProjectionFreshness is how current the read model was when it answered. +/// +/// Every successful Session query carries one. A response that parses is not +/// evidence that it reflects a write the caller just made, and a caller with no +/// way to tell will present a stale view as the truth. Reporting freshness on +/// every answer, rather than only when something is wrong, is what makes "this +/// is current" a statement the server made instead of one the caller assumed. +/// +/// This is query metadata. None of it is derived from Session events, and none +/// of it belongs in one: it describes the read path's progress, which is not a +/// fact about the session. +#[derive(Clone, Debug, Default)] +pub struct ProjectionFreshnessView<'a> { + /// Field 1: `condition` + pub condition: ::buffa::EnumValue, + /// Identifies the projection instance. A rebuild under a new generation + /// invalidates positions and orderings minted against the old one, which is + /// what page cursors bind to (see CursorValidity). + /// + /// Field 2: `projection_generation` + pub projection_generation: &'a str, + /// How far the projection has applied. For a session-scoped read this is a + /// SessionOrdinal on that session's stream, which is what a ConsistencyToken + /// is compared against. + /// + /// Field 3: `processed_watermark` + pub processed_watermark: u64, + /// Event time of the last applied event. Useful for a human-facing "as of", + /// and useless as a consistency boundary: event time is not monotonic across + /// writers, so a caller must compare watermarks, not timestamps. + /// + /// Field 4: `processed_at` + pub processed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// The source stream head as most recently observed. + /// + /// Unset means the head was not observed for this read, which is not the same + /// as a head of zero. Observing it costs a round trip the read path does not + /// always pay, so the contract lets a server decline rather than report a + /// fabricated value. When it is unset the condition is INDETERMINATE. + /// + /// Field 5: `source_high_watermark` + pub source_high_watermark: ::core::option::Option, + /// When source_high_watermark was observed. A cached observation is still + /// useful and still needs its age disclosed, because lag computed against a + /// stale head understates the real lag. + /// + /// Field 6: `source_observed_at` + pub source_observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Field 7: `consistency` + pub consistency: ::buffa::MessageFieldView< + super::super::__buffa::view::ConsistencyOutcomeView<'a>, + >, + /// Field 8: `source` + pub source: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProjectionFreshnessView<'a> { + /**Whether required field `condition` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_condition(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `projection_generation` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_projection_generation(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `processed_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_processed_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `consistency` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_consistency(&self) -> bool { + self.consistency.is_set() + } + /**Whether required field `source` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ProjectionFreshnessView<'a> { + type Owned = super::super::ProjectionFreshness; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.condition = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.projection_generation = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.processed_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.processed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.processed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source_high_watermark = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.consistency.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.consistency = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.source = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ProjectionFreshness, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ProjectionFreshness, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProjectionFreshness { + condition: self.condition, + projection_generation: self.projection_generation.to_string(), + processed_watermark: self.processed_watermark, + processed_at: match self.processed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_high_watermark: self.source_high_watermark, + source_observed_at: match self.source_observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + consistency: match self.consistency.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ConsistencyOutcome, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source: self.source, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProjectionFreshnessView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.condition.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if self.processed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.processed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.source_high_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.source_observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.source.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.condition.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(3u32, self.processed_watermark, buf); + if self.processed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.processed_at.write_to(__cache, buf); + } + if let Some(v) = self.source_high_watermark { + ::buffa::types::put_uint64_field(5u32, v, buf); + } + if self.source_observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_observed_at.write_to(__cache, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(8u32, self.source.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProjectionFreshnessView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("condition", &self.condition)?; + } + { + __map.serialize_entry("projectionGeneration", self.projection_generation)?; + } + { + __map + .serialize_entry( + "processedWatermark", + &::buffa::json_helpers::ProtoJson(&self.processed_watermark), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.processed_at.as_option() { + __map.serialize_entry("processedAt", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.source_high_watermark { + __map + .serialize_entry( + "sourceHighWatermark", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + { + if let ::core::option::Option::Some(__v) = self + .source_observed_at + .as_option() + { + __map.serialize_entry("sourceObservedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.consistency.as_option() { + __map.serialize_entry("consistency", __v)?; + } + } + { + __map.serialize_entry("source", &self.source)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProjectionFreshnessView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ProjectionFreshness"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness"; +} +::buffa::impl_default_view_instance!(ProjectionFreshnessView); +::buffa::impl_view_reborrow!(ProjectionFreshnessView); +/** Self-contained, `'static` owned view of a `ProjectionFreshness` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProjectionFreshnessView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProjectionFreshnessView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProjectionFreshnessOwnedView( + ::buffa::OwnedView>, +); +impl ProjectionFreshnessOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionFreshnessOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionFreshnessOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProjectionFreshness, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionFreshnessOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProjectionFreshnessView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProjectionFreshnessView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProjectionFreshness { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `condition` + #[must_use] + pub fn condition(&self) -> ::buffa::EnumValue { + self.0.reborrow().condition + } + /// Identifies the projection instance. A rebuild under a new generation + /// invalidates positions and orderings minted against the old one, which is + /// what page cursors bind to (see CursorValidity). + /// + /// Field 2: `projection_generation` + #[must_use] + pub fn projection_generation(&self) -> &'_ str { + self.0.reborrow().projection_generation + } + /// How far the projection has applied. For a session-scoped read this is a + /// SessionOrdinal on that session's stream, which is what a ConsistencyToken + /// is compared against. + /// + /// Field 3: `processed_watermark` + #[must_use] + pub fn processed_watermark(&self) -> u64 { + self.0.reborrow().processed_watermark + } + /// Event time of the last applied event. Useful for a human-facing "as of", + /// and useless as a consistency boundary: event time is not monotonic across + /// writers, so a caller must compare watermarks, not timestamps. + /// + /// Field 4: `processed_at` + #[must_use] + pub fn processed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().processed_at + } + /// The source stream head as most recently observed. + /// + /// Unset means the head was not observed for this read, which is not the same + /// as a head of zero. Observing it costs a round trip the read path does not + /// always pay, so the contract lets a server decline rather than report a + /// fabricated value. When it is unset the condition is INDETERMINATE. + /// + /// Field 5: `source_high_watermark` + #[must_use] + pub fn source_high_watermark(&self) -> ::core::option::Option { + self.0.reborrow().source_high_watermark + } + /// When source_high_watermark was observed. A cached observation is still + /// useful and still needs its age disclosed, because lag computed against a + /// stale head understates the real lag. + /// + /// Field 6: `source_observed_at` + #[must_use] + pub fn source_observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().source_observed_at + } + /// Field 7: `consistency` + #[must_use] + pub fn consistency( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ConsistencyOutcomeView<'_>, + > { + &self.0.reborrow().consistency + } + /// Field 8: `source` + #[must_use] + pub fn source(&self) -> ::buffa::EnumValue { + self.0.reborrow().source + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProjectionFreshnessOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ProjectionFreshnessOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProjectionFreshnessOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProjectionFreshnessOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProjectionFreshness { + type View<'a> = ProjectionFreshnessView<'a>; + type ViewHandle = ProjectionFreshnessOwnedView; +} +impl ::serde::Serialize for ProjectionFreshnessOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ConsistencyOutcome reports what the server did about the caller's +/// ReadConsistency, so a satisfied requirement is affirmed rather than implied +/// by the absence of an error. +#[derive(Clone, Debug, Default)] +pub struct ConsistencyOutcomeView<'a> { + /// Field 1: `result` + pub result: ::buffa::EnumValue, + /// How long the read waited before answering. Zero for both NOT_REQUESTED and + /// SATISFIED_IMMEDIATELY. + /// + /// Field 2: `waited_millis` + pub waited_millis: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> ConsistencyOutcomeView<'a> { + /**Whether required field `result` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_result(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `waited_millis` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_waited_millis(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ConsistencyOutcomeView<'a> { + type Owned = super::super::ConsistencyOutcome; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.waited_millis = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ConsistencyOutcome { + result: self.result, + waited_millis: self.waited_millis, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ConsistencyOutcomeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.waited_millis) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + ::buffa::types::put_uint32_field(2u32, self.waited_millis, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ConsistencyOutcomeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("result", &self.result)?; + } + { + __map + .serialize_entry( + "waitedMillis", + &::buffa::json_helpers::ProtoJson(&self.waited_millis), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ConsistencyOutcomeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ConsistencyOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome"; +} +::buffa::impl_default_view_instance!(ConsistencyOutcomeView); +::buffa::impl_view_reborrow!(ConsistencyOutcomeView); +/** Self-contained, `'static` owned view of a `ConsistencyOutcome` message. + + Wraps [`::buffa::OwnedView`]`<`[`ConsistencyOutcomeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ConsistencyOutcomeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ConsistencyOutcomeOwnedView( + ::buffa::OwnedView>, +); +impl ConsistencyOutcomeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyOutcomeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyOutcomeOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ConsistencyOutcome, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyOutcomeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ConsistencyOutcomeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ConsistencyOutcomeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ConsistencyOutcome { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `result` + #[must_use] + pub fn result(&self) -> ::buffa::EnumValue { + self.0.reborrow().result + } + /// How long the read waited before answering. Zero for both NOT_REQUESTED and + /// SATISFIED_IMMEDIATELY. + /// + /// Field 2: `waited_millis` + #[must_use] + pub fn waited_millis(&self) -> u32 { + self.0.reborrow().waited_millis + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ConsistencyOutcomeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ConsistencyOutcomeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ConsistencyOutcomeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ConsistencyOutcomeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ConsistencyOutcome { + type View<'a> = ConsistencyOutcomeView<'a>; + type ViewHandle = ConsistencyOutcomeOwnedView; +} +impl ::serde::Serialize for ConsistencyOutcomeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.rs new file mode 100644 index 0000000000..b5f01a0071 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.projection_freshness.rs @@ -0,0 +1,1030 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/projection_freshness.proto + +/// AnswerSource is what actually produced this answer. +/// +/// A projection that cannot serve does not have to mean the read fails. For a +/// read scoped to one session the server can fold that session's stream directly +/// and answer from the log, which is the authoritative source the projection is +/// only a cache of. The caller needs to be told, because the answer is better +/// than a projection answer and more expensive than one, and because a few +/// things it would normally be allowed to do with the response no longer hold. +/// +/// Falling back is admissible only for a session-scoped read. A read across +/// sessions has no bounded stream to fold, so a list query has exactly two +/// honest outcomes: a projection answer, or +/// QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE. Stating that here is cheaper than +/// discovering it the first time a degraded list query tries to replay a +/// tenant. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum AnswerSource { + ANSWER_SOURCE_UNSPECIFIED = 0i32, + /// Served from the materialized read model. + ANSWER_SOURCE_PROJECTION = 1i32, + /// Served by folding the session's own stream, because the projection could + /// not answer. + /// + /// The condition is CURRENT, since the fold ran to the head it read at. The + /// `projection_generation` is empty, because no projection instance produced + /// this and a synthetic id would be a generation a page cursor could bind to + /// that nothing is able to honor later. Which is the constraint that follows: + /// a replay answer must not mint a page cursor, so a caller needing to + /// paginate through a projection outage has to wait for the projection rather + /// than scan against a fallback. + ANSWER_SOURCE_AUTHORITATIVE_REPLAY = 2i32, +} +impl AnswerSource { + ///Idiomatic alias for [`Self::ANSWER_SOURCE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::ANSWER_SOURCE_UNSPECIFIED; + ///Idiomatic alias for [`Self::ANSWER_SOURCE_PROJECTION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Projection: Self = Self::ANSWER_SOURCE_PROJECTION; + ///Idiomatic alias for [`Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AuthoritativeReplay: Self = Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY; +} +impl ::core::default::Default for AnswerSource { + fn default() -> Self { + Self::ANSWER_SOURCE_UNSPECIFIED + } +} +impl ::serde::Serialize for AnswerSource { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for AnswerSource { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = AnswerSource; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(AnswerSource)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for AnswerSource { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for AnswerSource { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::ANSWER_SOURCE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::ANSWER_SOURCE_PROJECTION), + 2i32 => { + ::core::option::Option::Some(Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::ANSWER_SOURCE_UNSPECIFIED => "ANSWER_SOURCE_UNSPECIFIED", + Self::ANSWER_SOURCE_PROJECTION => "ANSWER_SOURCE_PROJECTION", + Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY => { + "ANSWER_SOURCE_AUTHORITATIVE_REPLAY" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "ANSWER_SOURCE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::ANSWER_SOURCE_UNSPECIFIED) + } + "ANSWER_SOURCE_PROJECTION" => { + ::core::option::Option::Some(Self::ANSWER_SOURCE_PROJECTION) + } + "ANSWER_SOURCE_AUTHORITATIVE_REPLAY" => { + ::core::option::Option::Some(Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::ANSWER_SOURCE_UNSPECIFIED, + Self::ANSWER_SOURCE_PROJECTION, + Self::ANSWER_SOURCE_AUTHORITATIVE_REPLAY, + ] + } +} +/// ProjectionCondition is the projection's state on the success path. +/// +/// It is deliberately smaller than the set of states a projection can be in. +/// Rebuilding, invalid, and missing are failure-path conditions: a projection in +/// one of those either serves nothing, in which case the caller gets +/// QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE with the matching reason, or serves a +/// readable prior generation, in which case it is simply LAGGING. Duplicating +/// them here would create two places to express one state and invite them to +/// disagree. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ProjectionCondition { + PROJECTION_CONDITION_UNSPECIFIED = 0i32, + /// Applied through the observed source head. Nothing known is missing. + PROJECTION_CONDITION_CURRENT = 1i32, + /// Known to be behind the observed source head. + PROJECTION_CONDITION_LAGGING = 2i32, + /// The source head was not observed, so currency could not be determined. + /// + /// This is not a degraded CURRENT. A caller that needs to know it is reading a + /// write it just made must state that with ReadConsistency rather than infer + /// it from a condition that says the server did not check. + PROJECTION_CONDITION_INDETERMINATE = 3i32, +} +impl ProjectionCondition { + ///Idiomatic alias for [`Self::PROJECTION_CONDITION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::PROJECTION_CONDITION_UNSPECIFIED; + ///Idiomatic alias for [`Self::PROJECTION_CONDITION_CURRENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Current: Self = Self::PROJECTION_CONDITION_CURRENT; + ///Idiomatic alias for [`Self::PROJECTION_CONDITION_LAGGING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Lagging: Self = Self::PROJECTION_CONDITION_LAGGING; + ///Idiomatic alias for [`Self::PROJECTION_CONDITION_INDETERMINATE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Indeterminate: Self = Self::PROJECTION_CONDITION_INDETERMINATE; +} +impl ::core::default::Default for ProjectionCondition { + fn default() -> Self { + Self::PROJECTION_CONDITION_UNSPECIFIED + } +} +impl ::serde::Serialize for ProjectionCondition { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ProjectionCondition { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ProjectionCondition; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ProjectionCondition) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProjectionCondition { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ProjectionCondition { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::PROJECTION_CONDITION_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::PROJECTION_CONDITION_CURRENT), + 2i32 => ::core::option::Option::Some(Self::PROJECTION_CONDITION_LAGGING), + 3i32 => { + ::core::option::Option::Some(Self::PROJECTION_CONDITION_INDETERMINATE) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::PROJECTION_CONDITION_UNSPECIFIED => "PROJECTION_CONDITION_UNSPECIFIED", + Self::PROJECTION_CONDITION_CURRENT => "PROJECTION_CONDITION_CURRENT", + Self::PROJECTION_CONDITION_LAGGING => "PROJECTION_CONDITION_LAGGING", + Self::PROJECTION_CONDITION_INDETERMINATE => { + "PROJECTION_CONDITION_INDETERMINATE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "PROJECTION_CONDITION_UNSPECIFIED" => { + ::core::option::Option::Some(Self::PROJECTION_CONDITION_UNSPECIFIED) + } + "PROJECTION_CONDITION_CURRENT" => { + ::core::option::Option::Some(Self::PROJECTION_CONDITION_CURRENT) + } + "PROJECTION_CONDITION_LAGGING" => { + ::core::option::Option::Some(Self::PROJECTION_CONDITION_LAGGING) + } + "PROJECTION_CONDITION_INDETERMINATE" => { + ::core::option::Option::Some(Self::PROJECTION_CONDITION_INDETERMINATE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::PROJECTION_CONDITION_UNSPECIFIED, + Self::PROJECTION_CONDITION_CURRENT, + Self::PROJECTION_CONDITION_LAGGING, + Self::PROJECTION_CONDITION_INDETERMINATE, + ] + } +} +/// ConsistencyResult is how a read's consistency requirement was resolved. +/// +/// There is no unsatisfied value. A requirement the server could not meet is a +/// failure, not a success carrying a flag, because a success shape with an +/// ignored flag is exactly what a caller in a hurry will read as an answer. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ConsistencyResult { + CONSISTENCY_RESULT_UNSPECIFIED = 0i32, + /// The caller asked for an eventual read. Freshness is still reported. + CONSISTENCY_RESULT_NOT_REQUESTED = 1i32, + /// The projection had already applied the required position. + CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY = 2i32, + /// The read waited for the projection to catch up, then answered. + CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT = 3i32, +} +impl ConsistencyResult { + ///Idiomatic alias for [`Self::CONSISTENCY_RESULT_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CONSISTENCY_RESULT_UNSPECIFIED; + ///Idiomatic alias for [`Self::CONSISTENCY_RESULT_NOT_REQUESTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotRequested: Self = Self::CONSISTENCY_RESULT_NOT_REQUESTED; + ///Idiomatic alias for [`Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SatisfiedImmediately: Self = Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY; + ///Idiomatic alias for [`Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SatisfiedAfterWait: Self = Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT; +} +impl ::core::default::Default for ConsistencyResult { + fn default() -> Self { + Self::CONSISTENCY_RESULT_UNSPECIFIED + } +} +impl ::serde::Serialize for ConsistencyResult { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ConsistencyResult { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ConsistencyResult; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ConsistencyResult) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConsistencyResult { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ConsistencyResult { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CONSISTENCY_RESULT_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CONSISTENCY_RESULT_NOT_REQUESTED), + 2i32 => { + ::core::option::Option::Some( + Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CONSISTENCY_RESULT_UNSPECIFIED => "CONSISTENCY_RESULT_UNSPECIFIED", + Self::CONSISTENCY_RESULT_NOT_REQUESTED => "CONSISTENCY_RESULT_NOT_REQUESTED", + Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY => { + "CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY" + } + Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT => { + "CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CONSISTENCY_RESULT_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CONSISTENCY_RESULT_UNSPECIFIED) + } + "CONSISTENCY_RESULT_NOT_REQUESTED" => { + ::core::option::Option::Some(Self::CONSISTENCY_RESULT_NOT_REQUESTED) + } + "CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY" => { + ::core::option::Option::Some( + Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY, + ) + } + "CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT" => { + ::core::option::Option::Some( + Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CONSISTENCY_RESULT_UNSPECIFIED, + Self::CONSISTENCY_RESULT_NOT_REQUESTED, + Self::CONSISTENCY_RESULT_SATISFIED_IMMEDIATELY, + Self::CONSISTENCY_RESULT_SATISFIED_AFTER_WAIT, + ] + } +} +/// ProjectionFreshness is how current the read model was when it answered. +/// +/// Every successful Session query carries one. A response that parses is not +/// evidence that it reflects a write the caller just made, and a caller with no +/// way to tell will present a stale view as the truth. Reporting freshness on +/// every answer, rather than only when something is wrong, is what makes "this +/// is current" a statement the server made instead of one the caller assumed. +/// +/// This is query metadata. None of it is derived from Session events, and none +/// of it belongs in one: it describes the read path's progress, which is not a +/// fact about the session. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProjectionFreshness { + /// Field 1: `condition` + #[serde(rename = "condition", with = "::buffa::json_helpers::proto_enum")] + pub condition: ::buffa::EnumValue, + /// Identifies the projection instance. A rebuild under a new generation + /// invalidates positions and orderings minted against the old one, which is + /// what page cursors bind to (see CursorValidity). + /// + /// Field 2: `projection_generation` + #[serde( + rename = "projectionGeneration", + alias = "projection_generation", + with = "::buffa::json_helpers::proto_string" + )] + pub projection_generation: ::buffa::alloc::string::String, + /// How far the projection has applied. For a session-scoped read this is a + /// SessionOrdinal on that session's stream, which is what a ConsistencyToken + /// is compared against. + /// + /// Field 3: `processed_watermark` + #[serde( + rename = "processedWatermark", + alias = "processed_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub processed_watermark: u64, + /// Event time of the last applied event. Useful for a human-facing "as of", + /// and useless as a consistency boundary: event time is not monotonic across + /// writers, so a caller must compare watermarks, not timestamps. + /// + /// Field 4: `processed_at` + #[serde( + rename = "processedAt", + alias = "processed_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub processed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// The source stream head as most recently observed. + /// + /// Unset means the head was not observed for this read, which is not the same + /// as a head of zero. Observing it costs a round trip the read path does not + /// always pay, so the contract lets a server decline rather than report a + /// fabricated value. When it is unset the condition is INDETERMINATE. + /// + /// Field 5: `source_high_watermark` + #[serde( + rename = "sourceHighWatermark", + alias = "source_high_watermark", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub source_high_watermark: ::core::option::Option, + /// When source_high_watermark was observed. A cached observation is still + /// useful and still needs its age disclosed, because lag computed against a + /// stale head understates the real lag. + /// + /// Field 6: `source_observed_at` + #[serde( + rename = "sourceObservedAt", + alias = "source_observed_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub source_observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// Field 7: `consistency` + #[serde(rename = "consistency")] + pub consistency: ::buffa::MessageField< + ConsistencyOutcome, + ::buffa::Inline, + >, + /// Field 8: `source` + #[serde(rename = "source", with = "::buffa::json_helpers::proto_enum")] + pub source: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for ProjectionFreshness { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProjectionFreshness") + .field("condition", &self.condition) + .field("projection_generation", &self.projection_generation) + .field("processed_watermark", &self.processed_watermark) + .field("processed_at", &self.processed_at) + .field("source_high_watermark", &self.source_high_watermark) + .field("source_observed_at", &self.source_observed_at) + .field("consistency", &self.consistency) + .field("source", &self.source) + .finish() + } +} +impl ProjectionFreshness { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness"; +} +impl ProjectionFreshness { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::source_high_watermark`] to `Some(value)`, consuming and returning `self`. + pub fn with_source_high_watermark(mut self, value: u64) -> Self { + self.source_high_watermark = Some(value); + self + } +} +::buffa::impl_default_instance!(ProjectionFreshness); +impl ::buffa::MessageName for ProjectionFreshness { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ProjectionFreshness"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness"; +} +impl ::buffa::Message for ProjectionFreshness { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.condition.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.projection_generation) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if self.processed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.processed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.source_high_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if self.source_observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.consistency.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.consistency.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.source.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.condition.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.projection_generation, buf); + ::buffa::types::put_uint64_field(3u32, self.processed_watermark, buf); + if self.processed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.processed_at.write_to(__cache, buf); + } + if let Some(v) = self.source_high_watermark { + ::buffa::types::put_uint64_field(5u32, v, buf); + } + if self.source_observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_observed_at.write_to(__cache, buf); + } + if self.consistency.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.consistency.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(8u32, self.source.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.condition = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.projection_generation, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.processed_watermark = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.processed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source_high_watermark = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.consistency.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.source = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.condition = ::buffa::EnumValue::from(0); + self.projection_generation.clear(); + self.processed_watermark = 0u64; + self.processed_at = ::buffa::MessageField::none(); + self.source_high_watermark = ::core::option::Option::None; + self.source_observed_at = ::buffa::MessageField::none(); + self.consistency = ::buffa::MessageField::none(); + self.source = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProjectionFreshness { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PROJECTION_FRESHNESS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionFreshness", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ConsistencyOutcome reports what the server did about the caller's +/// ReadConsistency, so a satisfied requirement is affirmed rather than implied +/// by the absence of an error. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ConsistencyOutcome { + /// Field 1: `result` + #[serde(rename = "result", with = "::buffa::json_helpers::proto_enum")] + pub result: ::buffa::EnumValue, + /// How long the read waited before answering. Zero for both NOT_REQUESTED and + /// SATISFIED_IMMEDIATELY. + /// + /// Field 2: `waited_millis` + #[serde( + rename = "waitedMillis", + alias = "waited_millis", + with = "::buffa::json_helpers::uint32" + )] + pub waited_millis: u32, +} +impl ::core::fmt::Debug for ConsistencyOutcome { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConsistencyOutcome") + .field("result", &self.result) + .field("waited_millis", &self.waited_millis) + .finish() + } +} +impl ConsistencyOutcome { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome"; +} +::buffa::impl_default_instance!(ConsistencyOutcome); +impl ::buffa::MessageName for ConsistencyOutcome { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ConsistencyOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome"; +} +impl ::buffa::Message for ConsistencyOutcome { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.result.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.waited_millis) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.result.to_i32(), buf); + ::buffa::types::put_uint32_field(2u32, self.waited_millis, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.result = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.waited_millis = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.result = ::buffa::EnumValue::from(0); + self.waited_millis = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConsistencyOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONSISTENCY_OUTCOME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyOutcome", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__oneof.rs new file mode 100644 index 0000000000..3198464d0c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__oneof.rs @@ -0,0 +1,94 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/query_error.proto + +pub mod query_error { + #[allow(unused_imports)] + use super::*; + /// Machine-readable specifics for the codes that have them. A caller must + /// tolerate an unset detail: a code may gain one additively, and an older + /// caller will not decode a variant added after its minor. + #[derive(Clone, PartialEq, Debug)] + pub enum Detail { + UnsupportedContractVersion( + ::buffa::alloc::boxed::Box< + super::super::super::UnsupportedContractVersionDetail, + >, + ), + StaleCursor(::buffa::alloc::boxed::Box), + ProjectionUnavailable( + ::buffa::alloc::boxed::Box, + ), + InvalidArgument( + ::buffa::alloc::boxed::Box, + ), + } + impl ::buffa::Oneof for Detail {} + impl From for Detail { + fn from(v: super::super::super::UnsupportedContractVersionDetail) -> Self { + Self::UnsupportedContractVersion(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::UnsupportedContractVersionDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::StaleCursorDetail) -> Self { + Self::StaleCursor(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::StaleCursorDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::ProjectionUnavailableDetail) -> Self { + Self::ProjectionUnavailable(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::ProjectionUnavailableDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl From for Detail { + fn from(v: super::super::super::InvalidArgumentDetail) -> Self { + Self::InvalidArgument(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::InvalidArgumentDetail) -> Self { + Self::Some(Detail::from(v)) + } + } + impl serde::Serialize for Detail { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::UnsupportedContractVersion(v) => { + map.serialize_entry("unsupportedContractVersion", v)?; + } + Self::StaleCursor(v) => { + map.serialize_entry("staleCursor", v)?; + } + Self::ProjectionUnavailable(v) => { + map.serialize_entry("projectionUnavailable", v)?; + } + Self::InvalidArgument(v) => { + map.serialize_entry("invalidArgument", v)?; + } + } + map.end() + } + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view.rs new file mode 100644 index 0000000000..d31b6a20e3 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view.rs @@ -0,0 +1,2294 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/query_error.proto + +/// QueryError is the typed failure payload for every Session query. +/// +/// It is not carried inside a success response. A query either answers or +/// fails, and collapsing the two into one message invites a caller to read a +/// zero-valued success shape as an empty result. On the JSON-RPC-over-NATS +/// binding (ADR#0056) this rides in the error object's `data`; the numeric code +/// assignment is a separate reservation and is deliberately not invented here. +/// +/// `code` is the machine-readable discriminant and the only field a caller +/// should branch on. `message` is for humans and may change at any time without +/// a version bump, so treating it as an API is a bug. +#[derive(Clone, Debug, Default)] +pub struct QueryErrorView<'a> { + /// Field 1: `code` + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 2: `message` + pub message: &'a str, + pub detail: ::core::option::Option< + super::super::__buffa::view::oneof::query_error::Detail<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> QueryErrorView<'a> { + /**Whether required field `code` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_code(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for QueryErrorView<'a> { + type Owned = super::super::QueryError; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.code = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + ref mut existing, + ), + ) = view.detail + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.detail = Some( + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::QueryError { + code: self.code, + message: self.message.to_string(), + detail: match self.detail.as_ref() { + ::core::option::Option::Some(v) => { + ::core::option::Option::Some( + match v { + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + v, + ) => { + super::super::__buffa::oneof::query_error::Detail::UnsupportedContractVersion( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + v, + ) => { + super::super::__buffa::oneof::query_error::Detail::StaleCursor( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + v, + ) => { + super::super::__buffa::oneof::query_error::Detail::ProjectionUnavailable( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + v, + ) => { + super::super::__buffa::oneof::query_error::Detail::InvalidArgument( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + }, + ) + } + ::core::option::Option::None => ::core::option::Option::None, + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for QueryErrorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for QueryErrorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("code", &self.code)?; + } + { + __map.serialize_entry("message", self.message)?; + } + if let ::core::option::Option::Some(ref __ov) = self.detail { + match __ov { + super::super::__buffa::view::oneof::query_error::Detail::UnsupportedContractVersion( + v, + ) => { + __map.serialize_entry("unsupportedContractVersion", v)?; + } + super::super::__buffa::view::oneof::query_error::Detail::StaleCursor( + v, + ) => { + __map.serialize_entry("staleCursor", v)?; + } + super::super::__buffa::view::oneof::query_error::Detail::ProjectionUnavailable( + v, + ) => { + __map.serialize_entry("projectionUnavailable", v)?; + } + super::super::__buffa::view::oneof::query_error::Detail::InvalidArgument( + v, + ) => { + __map.serialize_entry("invalidArgument", v)?; + } + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for QueryErrorView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "QueryError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.QueryError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.QueryError"; +} +::buffa::impl_default_view_instance!(QueryErrorView); +::buffa::impl_view_reborrow!(QueryErrorView); +/** Self-contained, `'static` owned view of a `QueryError` message. + + Wraps [`::buffa::OwnedView`]`<`[`QueryErrorView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`QueryErrorView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct QueryErrorOwnedView(::buffa::OwnedView>); +impl QueryErrorOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + QueryErrorOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + QueryErrorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::QueryError, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + QueryErrorOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`QueryErrorView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &QueryErrorView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::QueryError { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `code` + #[must_use] + pub fn code(&self) -> ::buffa::EnumValue { + self.0.reborrow().code + } + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 2: `message` + #[must_use] + pub fn message(&self) -> &'_ str { + self.0.reborrow().message + } + /// Oneof `detail`. + #[must_use] + pub fn detail( + &self, + ) -> ::core::option::Option< + &super::super::__buffa::view::oneof::query_error::Detail<'_>, + > { + self.0.reborrow().detail.as_ref() + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for QueryErrorOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + QueryErrorOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: QueryErrorOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for QueryErrorOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::QueryError { + type View<'a> = QueryErrorView<'a>; + type ViewHandle = QueryErrorOwnedView; +} +impl ::serde::Serialize for QueryErrorOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// UnsupportedContractVersionDetail tells the caller what it would have to +/// speak, so an incompatibility is actionable rather than merely reported. +#[derive(Clone, Debug, Default)] +pub struct UnsupportedContractVersionDetailView<'a> { + /// Field 1: `requested` + pub requested: ::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'a>, + >, + /// Inclusive range of majors this server can render. + /// + /// Field 2: `supported_major_min` + pub supported_major_min: u32, + /// Field 3: `supported_major_max` + pub supported_major_max: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UnsupportedContractVersionDetailView<'a> { + /**Whether required field `requested` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_requested(&self) -> bool { + self.requested.is_set() + } + /**Whether required field `supported_major_min` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_supported_major_min(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `supported_major_max` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_supported_major_max(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UnsupportedContractVersionDetailView<'a> { + type Owned = super::super::UnsupportedContractVersionDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.requested.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.requested = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.supported_major_min = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.supported_major_max = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::UnsupportedContractVersionDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::UnsupportedContractVersionDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UnsupportedContractVersionDetail { + requested: match self.requested.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContractVersion, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + supported_major_min: self.supported_major_min, + supported_major_max: self.supported_major_max, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UnsupportedContractVersionDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.requested.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.requested.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.supported_major_min) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.supported_major_max) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.requested.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.requested.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(2u32, self.supported_major_min, buf); + ::buffa::types::put_uint32_field(3u32, self.supported_major_max, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UnsupportedContractVersionDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.requested.as_option() { + __map.serialize_entry("requested", __v)?; + } + } + { + __map + .serialize_entry( + "supportedMajorMin", + &::buffa::json_helpers::ProtoJson(&self.supported_major_min), + )?; + } + { + __map + .serialize_entry( + "supportedMajorMax", + &::buffa::json_helpers::ProtoJson(&self.supported_major_max), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UnsupportedContractVersionDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "UnsupportedContractVersionDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail"; +} +::buffa::impl_default_view_instance!(UnsupportedContractVersionDetailView); +::buffa::impl_view_reborrow!(UnsupportedContractVersionDetailView); +/** Self-contained, `'static` owned view of a `UnsupportedContractVersionDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`UnsupportedContractVersionDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UnsupportedContractVersionDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UnsupportedContractVersionDetailOwnedView( + ::buffa::OwnedView>, +); +impl UnsupportedContractVersionDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnsupportedContractVersionDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnsupportedContractVersionDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UnsupportedContractVersionDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnsupportedContractVersionDetailOwnedView( + ::buffa::OwnedView::from_owned(msg)?, + ), + ) + } + /// Borrow the full [`UnsupportedContractVersionDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UnsupportedContractVersionDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UnsupportedContractVersionDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `requested` + #[must_use] + pub fn requested( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ContractVersionView<'_>, + > { + &self.0.reborrow().requested + } + /// Inclusive range of majors this server can render. + /// + /// Field 2: `supported_major_min` + #[must_use] + pub fn supported_major_min(&self) -> u32 { + self.0.reborrow().supported_major_min + } + /// Field 3: `supported_major_max` + #[must_use] + pub fn supported_major_max(&self) -> u32 { + self.0.reborrow().supported_major_max + } +} +impl ::core::convert::From< + ::buffa::OwnedView>, +> for UnsupportedContractVersionDetailOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + UnsupportedContractVersionDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UnsupportedContractVersionDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef< + ::buffa::OwnedView>, +> for UnsupportedContractVersionDetailOwnedView { + fn as_ref( + &self, + ) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UnsupportedContractVersionDetail { + type View<'a> = UnsupportedContractVersionDetailView<'a>; + type ViewHandle = UnsupportedContractVersionDetailOwnedView; +} +impl ::serde::Serialize for UnsupportedContractVersionDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// StaleCursorDetail says why a previously valid cursor stopped being valid, so +/// a caller can tell a benign restart from a view that changed underneath it. +#[derive(Clone, Debug, Default)] +pub struct StaleCursorDetailView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> StaleCursorDetailView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StaleCursorDetailView<'a> { + type Owned = super::super::StaleCursorDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StaleCursorDetail { + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StaleCursorDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StaleCursorDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StaleCursorDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "StaleCursorDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail"; +} +::buffa::impl_default_view_instance!(StaleCursorDetailView); +::buffa::impl_view_reborrow!(StaleCursorDetailView); +/** Self-contained, `'static` owned view of a `StaleCursorDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`StaleCursorDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StaleCursorDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StaleCursorDetailOwnedView( + ::buffa::OwnedView>, +); +impl StaleCursorDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StaleCursorDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StaleCursorDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StaleCursorDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StaleCursorDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StaleCursorDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StaleCursorDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StaleCursorDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StaleCursorDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StaleCursorDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StaleCursorDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StaleCursorDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StaleCursorDetail { + type View<'a> = StaleCursorDetailView<'a>; + type ViewHandle = StaleCursorDetailOwnedView; +} +impl ::serde::Serialize for StaleCursorDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ProjectionUnavailableDetail distinguishes "come back shortly" from "this is +/// broken", which a caller cannot guess from the code alone. +#[derive(Clone, Debug, Default)] +pub struct ProjectionUnavailableDetailView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + /// How current the projection was when it gave up. Present for REASON_LAGGING, + /// where it is the difference between an actionable failure and a bare one: a + /// caller that can see it reached the required position minus two can retry + /// with a larger budget, while one that cannot see it can only guess. + /// + /// Field 2: `freshness` + pub freshness: ::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'a>, + >, + /// How far along the rebuild is. Present for REASON_REBUILDING when the + /// rebuilder can report it. + /// + /// Without this, "come back shortly" is a claim with no number attached, and a + /// caller has to choose between polling a rebuild that will take four hours + /// and giving up on one that will take four seconds. Absent means the + /// rebuilder could not say, which is different from a rebuild that has made no + /// progress. + /// + /// Field 3: `rebuild` + pub rebuild: ::buffa::MessageFieldView< + super::super::__buffa::view::RebuildProgressView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProjectionUnavailableDetailView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ProjectionUnavailableDetailView<'a> { + type Owned = super::super::ProjectionUnavailableDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.freshness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.freshness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.rebuild.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.rebuild = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ProjectionUnavailableDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ProjectionUnavailableDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProjectionUnavailableDetail { + reason: self.reason, + freshness: match self.freshness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProjectionFreshness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + rebuild: match self.rebuild.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::RebuildProgress, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProjectionUnavailableDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.rebuild.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.rebuild.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + if self.rebuild.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.rebuild.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProjectionUnavailableDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + { + if let ::core::option::Option::Some(__v) = self.freshness.as_option() { + __map.serialize_entry("freshness", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.rebuild.as_option() { + __map.serialize_entry("rebuild", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProjectionUnavailableDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ProjectionUnavailableDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail"; +} +::buffa::impl_default_view_instance!(ProjectionUnavailableDetailView); +::buffa::impl_view_reborrow!(ProjectionUnavailableDetailView); +/** Self-contained, `'static` owned view of a `ProjectionUnavailableDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProjectionUnavailableDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProjectionUnavailableDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProjectionUnavailableDetailOwnedView( + ::buffa::OwnedView>, +); +impl ProjectionUnavailableDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionUnavailableDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionUnavailableDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProjectionUnavailableDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProjectionUnavailableDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProjectionUnavailableDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProjectionUnavailableDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProjectionUnavailableDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// How current the projection was when it gave up. Present for REASON_LAGGING, + /// where it is the difference between an actionable failure and a bare one: a + /// caller that can see it reached the required position minus two can retry + /// with a larger budget, while one that cannot see it can only guess. + /// + /// Field 2: `freshness` + #[must_use] + pub fn freshness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProjectionFreshnessView<'_>, + > { + &self.0.reborrow().freshness + } + /// How far along the rebuild is. Present for REASON_REBUILDING when the + /// rebuilder can report it. + /// + /// Without this, "come back shortly" is a claim with no number attached, and a + /// caller has to choose between polling a rebuild that will take four hours + /// and giving up on one that will take four seconds. Absent means the + /// rebuilder could not say, which is different from a rebuild that has made no + /// progress. + /// + /// Field 3: `rebuild` + #[must_use] + pub fn rebuild( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::RebuildProgressView<'_>, + > { + &self.0.reborrow().rebuild + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProjectionUnavailableDetailOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + ProjectionUnavailableDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProjectionUnavailableDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProjectionUnavailableDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProjectionUnavailableDetail { + type View<'a> = ProjectionUnavailableDetailView<'a>; + type ViewHandle = ProjectionUnavailableDetailOwnedView; +} +impl ::serde::Serialize for ProjectionUnavailableDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RebuildProgress is how far a projection rebuild has got. +#[derive(Clone, Debug, Default)] +pub struct RebuildProgressView<'a> { + /// Field 1: `started_at` + pub started_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Position the rebuild has applied through, in the same units the finished + /// projection will report as its processed watermark. + /// + /// Field 2: `processed_watermark` + pub processed_watermark: u64, + /// Position the rebuild is working toward, as known when it started. + /// + /// Unset when the rebuilder does not know its own end, which is the honest + /// answer for a rebuild over a stream that is still being written to. Reported + /// as unset rather than as the current head, because a target that moves is a + /// percentage that goes backwards. + /// + /// Field 3: `target_watermark` + pub target_watermark: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RebuildProgressView<'a> { + /**Whether required field `started_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_started_at(&self) -> bool { + self.started_at.is_set() + } + /**Whether required field `processed_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_processed_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RebuildProgressView<'a> { + type Owned = super::super::RebuildProgress; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.started_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.started_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.processed_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.target_watermark = Some(::buffa::types::decode_uint64(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RebuildProgress { + started_at: match self.started_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + processed_watermark: self.processed_watermark, + target_watermark: self.target_watermark, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RebuildProgressView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if let Some(v) = self.target_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(2u32, self.processed_watermark, buf); + if let Some(v) = self.target_watermark { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RebuildProgressView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.started_at.as_option() { + __map.serialize_entry("startedAt", __v)?; + } + } + { + __map + .serialize_entry( + "processedWatermark", + &::buffa::json_helpers::ProtoJson(&self.processed_watermark), + )?; + } + if let ::core::option::Option::Some(__v) = self.target_watermark { + __map + .serialize_entry( + "targetWatermark", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RebuildProgressView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "RebuildProgress"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.RebuildProgress"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RebuildProgress"; +} +::buffa::impl_default_view_instance!(RebuildProgressView); +::buffa::impl_view_reborrow!(RebuildProgressView); +/** Self-contained, `'static` owned view of a `RebuildProgress` message. + + Wraps [`::buffa::OwnedView`]`<`[`RebuildProgressView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RebuildProgressView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RebuildProgressOwnedView(::buffa::OwnedView>); +impl RebuildProgressOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RebuildProgressOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RebuildProgressOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RebuildProgress, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RebuildProgressOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RebuildProgressView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RebuildProgressView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RebuildProgress { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `started_at` + #[must_use] + pub fn started_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().started_at + } + /// Position the rebuild has applied through, in the same units the finished + /// projection will report as its processed watermark. + /// + /// Field 2: `processed_watermark` + #[must_use] + pub fn processed_watermark(&self) -> u64 { + self.0.reborrow().processed_watermark + } + /// Position the rebuild is working toward, as known when it started. + /// + /// Unset when the rebuilder does not know its own end, which is the honest + /// answer for a rebuild over a stream that is still being written to. Reported + /// as unset rather than as the current head, because a target that moves is a + /// percentage that goes backwards. + /// + /// Field 3: `target_watermark` + #[must_use] + pub fn target_watermark(&self) -> ::core::option::Option { + self.0.reborrow().target_watermark + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RebuildProgressOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RebuildProgressOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RebuildProgressOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RebuildProgressOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RebuildProgress { + type View<'a> = RebuildProgressView<'a>; + type ViewHandle = RebuildProgressOwnedView; +} +impl ::serde::Serialize for RebuildProgressOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// InvalidArgumentDetail names the offending input. It carries a field path +/// rather than a rendered sentence so a caller can map the failure back to its +/// own request structure. +#[derive(Clone, Debug, Default)] +pub struct InvalidArgumentDetailView<'a> { + /// Dotted path into the request message, for example `page_size`. + /// + /// Field 1: `field_path` + pub field_path: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> InvalidArgumentDetailView<'a> { + /**Whether required field `field_path` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_field_path(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for InvalidArgumentDetailView<'a> { + type Owned = super::super::InvalidArgumentDetail; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.field_path = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::InvalidArgumentDetail, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::InvalidArgumentDetail, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::InvalidArgumentDetail { + field_path: self.field_path.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for InvalidArgumentDetailView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.field_path) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.field_path, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for InvalidArgumentDetailView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("fieldPath", self.field_path)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for InvalidArgumentDetailView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "InvalidArgumentDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail"; +} +::buffa::impl_default_view_instance!(InvalidArgumentDetailView); +::buffa::impl_view_reborrow!(InvalidArgumentDetailView); +/** Self-contained, `'static` owned view of a `InvalidArgumentDetail` message. + + Wraps [`::buffa::OwnedView`]`<`[`InvalidArgumentDetailView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`InvalidArgumentDetailView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct InvalidArgumentDetailOwnedView( + ::buffa::OwnedView>, +); +impl InvalidArgumentDetailOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InvalidArgumentDetailOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InvalidArgumentDetailOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::InvalidArgumentDetail, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + InvalidArgumentDetailOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`InvalidArgumentDetailView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &InvalidArgumentDetailView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::InvalidArgumentDetail { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Dotted path into the request message, for example `page_size`. + /// + /// Field 1: `field_path` + #[must_use] + pub fn field_path(&self) -> &'_ str { + self.0.reborrow().field_path + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for InvalidArgumentDetailOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + InvalidArgumentDetailOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: InvalidArgumentDetailOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for InvalidArgumentDetailOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::InvalidArgumentDetail { + type View<'a> = InvalidArgumentDetailView<'a>; + type ViewHandle = InvalidArgumentDetailOwnedView; +} +impl ::serde::Serialize for InvalidArgumentDetailOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view_oneof.rs new file mode 100644 index 0000000000..f4f949a8c0 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.__view_oneof.rs @@ -0,0 +1,34 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/query_error.proto + +pub mod query_error { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Detail<'a> { + UnsupportedContractVersion( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::UnsupportedContractVersionDetailView< + 'a, + >, + >, + ), + StaleCursor( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::StaleCursorDetailView<'a>, + >, + ), + ProjectionUnavailable( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::ProjectionUnavailableDetailView< + 'a, + >, + >, + ), + InvalidArgument( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::InvalidArgumentDetailView<'a>, + >, + ), + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.rs new file mode 100644 index 0000000000..4ed1c68287 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.query_error.rs @@ -0,0 +1,1967 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/query_error.proto + +/// QueryErrorCode is the closed set of reasons a Session query fails. +/// +/// A caller that receives an unknown value here has reached a server newer than +/// its contract minor and must treat it as a non-retryable failure, not as +/// success and not as an unconditional retry. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum QueryErrorCode { + QUERY_ERROR_CODE_UNSPECIFIED = 0i32, + /// The session id resolves to no stream. Distinct from an existing session the + /// caller may not see, which is QUERY_ERROR_CODE_PERMISSION_DENIED, so that + /// probing cannot use the difference to prove existence. + QUERY_ERROR_CODE_SESSION_NOT_FOUND = 1i32, + /// The caller's declared major is one this server cannot render. Fail closed: + /// answering in an unreadable shape is worse than not answering. + QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION = 2i32, + /// The request is malformed: an unparsable id, a page size out of range, a + /// filter combination with no meaning. + QUERY_ERROR_CODE_INVALID_ARGUMENT = 3i32, + /// The page token was minted by this contract but no longer names a valid + /// position. See CursorValidity for what a cursor binds to and + /// StaleCursorReason for which binding broke. Restarting the scan is the fix. + QUERY_ERROR_CODE_STALE_CURSOR = 4i32, + /// The page token was not minted by this contract, is corrupt, fails its MAC, + /// or does not match the request it was presented with. Distinct from stale: + /// stale means it was valid and the view moved, so a caller can restart the + /// scan; malformed means the caller sent something this server never issued + /// for this request, and retrying will not help. + QUERY_ERROR_CODE_MALFORMED_CURSOR = 5i32, + /// The backing projection cannot serve the read as asked. Also how an + /// unsatisfiable ReadConsistency is reported: a requirement the server could + /// not meet is a failure, not a success carrying a flag. + QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE = 6i32, + /// The caller is not authorized for this session. Returned in place of + /// NOT_FOUND when disclosing the difference would leak existence. + QUERY_ERROR_CODE_PERMISSION_DENIED = 7i32, + /// The request is valid but too expensive to serve as asked, for example a + /// page size above the configured admission limit. + QUERY_ERROR_CODE_RESOURCE_EXHAUSTED = 8i32, + /// An unexpected server-side failure. Carries no detail on purpose. + QUERY_ERROR_CODE_INTERNAL = 9i32, +} +impl QueryErrorCode { + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::QUERY_ERROR_CODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SessionNotFound: Self = Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnsupportedContractVersion: Self = Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_INVALID_ARGUMENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InvalidArgument: Self = Self::QUERY_ERROR_CODE_INVALID_ARGUMENT; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_STALE_CURSOR`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const StaleCursor: Self = Self::QUERY_ERROR_CODE_STALE_CURSOR; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_MALFORMED_CURSOR`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MalformedCursor: Self = Self::QUERY_ERROR_CODE_MALFORMED_CURSOR; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionUnavailable: Self = Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_PERMISSION_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PermissionDenied: Self = Self::QUERY_ERROR_CODE_PERMISSION_DENIED; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ResourceExhausted: Self = Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED; + ///Idiomatic alias for [`Self::QUERY_ERROR_CODE_INTERNAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Internal: Self = Self::QUERY_ERROR_CODE_INTERNAL; +} +impl ::core::default::Default for QueryErrorCode { + fn default() -> Self { + Self::QUERY_ERROR_CODE_UNSPECIFIED + } +} +impl ::serde::Serialize for QueryErrorCode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for QueryErrorCode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = QueryErrorCode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(QueryErrorCode) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for QueryErrorCode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for QueryErrorCode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::QUERY_ERROR_CODE_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND) + } + 2i32 => { + ::core::option::Option::Some( + Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION, + ) + } + 3i32 => ::core::option::Option::Some(Self::QUERY_ERROR_CODE_INVALID_ARGUMENT), + 4i32 => ::core::option::Option::Some(Self::QUERY_ERROR_CODE_STALE_CURSOR), + 5i32 => ::core::option::Option::Some(Self::QUERY_ERROR_CODE_MALFORMED_CURSOR), + 6i32 => { + ::core::option::Option::Some( + Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE, + ) + } + 7i32 => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_PERMISSION_DENIED) + } + 8i32 => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED) + } + 9i32 => ::core::option::Option::Some(Self::QUERY_ERROR_CODE_INTERNAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::QUERY_ERROR_CODE_UNSPECIFIED => "QUERY_ERROR_CODE_UNSPECIFIED", + Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND => { + "QUERY_ERROR_CODE_SESSION_NOT_FOUND" + } + Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION => { + "QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION" + } + Self::QUERY_ERROR_CODE_INVALID_ARGUMENT => { + "QUERY_ERROR_CODE_INVALID_ARGUMENT" + } + Self::QUERY_ERROR_CODE_STALE_CURSOR => "QUERY_ERROR_CODE_STALE_CURSOR", + Self::QUERY_ERROR_CODE_MALFORMED_CURSOR => { + "QUERY_ERROR_CODE_MALFORMED_CURSOR" + } + Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE => { + "QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE" + } + Self::QUERY_ERROR_CODE_PERMISSION_DENIED => { + "QUERY_ERROR_CODE_PERMISSION_DENIED" + } + Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED => { + "QUERY_ERROR_CODE_RESOURCE_EXHAUSTED" + } + Self::QUERY_ERROR_CODE_INTERNAL => "QUERY_ERROR_CODE_INTERNAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "QUERY_ERROR_CODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_UNSPECIFIED) + } + "QUERY_ERROR_CODE_SESSION_NOT_FOUND" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND) + } + "QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION" => { + ::core::option::Option::Some( + Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION, + ) + } + "QUERY_ERROR_CODE_INVALID_ARGUMENT" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_INVALID_ARGUMENT) + } + "QUERY_ERROR_CODE_STALE_CURSOR" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_STALE_CURSOR) + } + "QUERY_ERROR_CODE_MALFORMED_CURSOR" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_MALFORMED_CURSOR) + } + "QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE" => { + ::core::option::Option::Some( + Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE, + ) + } + "QUERY_ERROR_CODE_PERMISSION_DENIED" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_PERMISSION_DENIED) + } + "QUERY_ERROR_CODE_RESOURCE_EXHAUSTED" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED) + } + "QUERY_ERROR_CODE_INTERNAL" => { + ::core::option::Option::Some(Self::QUERY_ERROR_CODE_INTERNAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::QUERY_ERROR_CODE_UNSPECIFIED, + Self::QUERY_ERROR_CODE_SESSION_NOT_FOUND, + Self::QUERY_ERROR_CODE_UNSUPPORTED_CONTRACT_VERSION, + Self::QUERY_ERROR_CODE_INVALID_ARGUMENT, + Self::QUERY_ERROR_CODE_STALE_CURSOR, + Self::QUERY_ERROR_CODE_MALFORMED_CURSOR, + Self::QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE, + Self::QUERY_ERROR_CODE_PERMISSION_DENIED, + Self::QUERY_ERROR_CODE_RESOURCE_EXHAUSTED, + Self::QUERY_ERROR_CODE_INTERNAL, + ] + } +} +/// StaleCursorReason is what invalidated a cursor. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum StaleCursorReason { + STALE_CURSOR_REASON_UNSPECIFIED = 0i32, + /// A rewind moved the effective history boundary the cursor was anchored to. + STALE_CURSOR_REASON_REWOUND = 1i32, + /// A redaction or artifact erasure changed the prefix the cursor covered. + STALE_CURSOR_REASON_PRIVACY_CHANGED = 2i32, + /// The projection the cursor was minted against was replaced or rebuilt. + STALE_CURSOR_REASON_PROJECTION_REPLACED = 3i32, + /// The cursor was minted under a contract version this server no longer + /// renders. + STALE_CURSOR_REASON_CONTRACT_CHANGED = 4i32, + /// The cursor outlived the window a pinned scan is held open for. Nothing + /// about the session changed; the scan simply took too long. + STALE_CURSOR_REASON_EXPIRED = 5i32, + /// A compaction replaced a span the cursor was scanning. Reported separately + /// from REWOUND because nothing was retracted: the same history is still + /// there, summarized, and a caller may reasonably restart without treating it + /// as loss. + STALE_CURSOR_REASON_COMPACTED = 6i32, +} +impl StaleCursorReason { + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::STALE_CURSOR_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_REWOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Rewound: Self = Self::STALE_CURSOR_REASON_REWOUND; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_PRIVACY_CHANGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PrivacyChanged: Self = Self::STALE_CURSOR_REASON_PRIVACY_CHANGED; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_PROJECTION_REPLACED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProjectionReplaced: Self = Self::STALE_CURSOR_REASON_PROJECTION_REPLACED; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_CONTRACT_CHANGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ContractChanged: Self = Self::STALE_CURSOR_REASON_CONTRACT_CHANGED; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_EXPIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Expired: Self = Self::STALE_CURSOR_REASON_EXPIRED; + ///Idiomatic alias for [`Self::STALE_CURSOR_REASON_COMPACTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Compacted: Self = Self::STALE_CURSOR_REASON_COMPACTED; +} +impl ::core::default::Default for StaleCursorReason { + fn default() -> Self { + Self::STALE_CURSOR_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for StaleCursorReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for StaleCursorReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = StaleCursorReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(StaleCursorReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for StaleCursorReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for StaleCursorReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::STALE_CURSOR_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::STALE_CURSOR_REASON_REWOUND), + 2i32 => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_PRIVACY_CHANGED) + } + 3i32 => { + ::core::option::Option::Some( + Self::STALE_CURSOR_REASON_PROJECTION_REPLACED, + ) + } + 4i32 => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_CONTRACT_CHANGED) + } + 5i32 => ::core::option::Option::Some(Self::STALE_CURSOR_REASON_EXPIRED), + 6i32 => ::core::option::Option::Some(Self::STALE_CURSOR_REASON_COMPACTED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::STALE_CURSOR_REASON_UNSPECIFIED => "STALE_CURSOR_REASON_UNSPECIFIED", + Self::STALE_CURSOR_REASON_REWOUND => "STALE_CURSOR_REASON_REWOUND", + Self::STALE_CURSOR_REASON_PRIVACY_CHANGED => { + "STALE_CURSOR_REASON_PRIVACY_CHANGED" + } + Self::STALE_CURSOR_REASON_PROJECTION_REPLACED => { + "STALE_CURSOR_REASON_PROJECTION_REPLACED" + } + Self::STALE_CURSOR_REASON_CONTRACT_CHANGED => { + "STALE_CURSOR_REASON_CONTRACT_CHANGED" + } + Self::STALE_CURSOR_REASON_EXPIRED => "STALE_CURSOR_REASON_EXPIRED", + Self::STALE_CURSOR_REASON_COMPACTED => "STALE_CURSOR_REASON_COMPACTED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "STALE_CURSOR_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_UNSPECIFIED) + } + "STALE_CURSOR_REASON_REWOUND" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_REWOUND) + } + "STALE_CURSOR_REASON_PRIVACY_CHANGED" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_PRIVACY_CHANGED) + } + "STALE_CURSOR_REASON_PROJECTION_REPLACED" => { + ::core::option::Option::Some( + Self::STALE_CURSOR_REASON_PROJECTION_REPLACED, + ) + } + "STALE_CURSOR_REASON_CONTRACT_CHANGED" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_CONTRACT_CHANGED) + } + "STALE_CURSOR_REASON_EXPIRED" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_EXPIRED) + } + "STALE_CURSOR_REASON_COMPACTED" => { + ::core::option::Option::Some(Self::STALE_CURSOR_REASON_COMPACTED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::STALE_CURSOR_REASON_UNSPECIFIED, + Self::STALE_CURSOR_REASON_REWOUND, + Self::STALE_CURSOR_REASON_PRIVACY_CHANGED, + Self::STALE_CURSOR_REASON_PROJECTION_REPLACED, + Self::STALE_CURSOR_REASON_CONTRACT_CHANGED, + Self::STALE_CURSOR_REASON_EXPIRED, + Self::STALE_CURSOR_REASON_COMPACTED, + ] + } +} +/// ProjectionUnavailableReason is why the read could not be served. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ProjectionUnavailableReason { + PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED = 0i32, + /// A rebuild is in progress and no prior generation is readable; the read is + /// expected to succeed later. A rebuild that keeps the prior generation + /// readable is not this: it answers, with PROJECTION_CONDITION_LAGGING. + PROJECTION_UNAVAILABLE_REASON_REBUILDING = 1i32, + /// The projection is present but failed its own validity checks. + PROJECTION_UNAVAILABLE_REASON_INVALID = 2i32, + /// No projection exists for this scope yet. + PROJECTION_UNAVAILABLE_REASON_MISSING = 3i32, + /// The projection is too far behind to satisfy the requested consistency. + PROJECTION_UNAVAILABLE_REASON_LAGGING = 4i32, +} +impl ProjectionUnavailableReason { + ///Idiomatic alias for [`Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Rebuilding: Self = Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING; + ///Idiomatic alias for [`Self::PROJECTION_UNAVAILABLE_REASON_INVALID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Invalid: Self = Self::PROJECTION_UNAVAILABLE_REASON_INVALID; + ///Idiomatic alias for [`Self::PROJECTION_UNAVAILABLE_REASON_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Missing: Self = Self::PROJECTION_UNAVAILABLE_REASON_MISSING; + ///Idiomatic alias for [`Self::PROJECTION_UNAVAILABLE_REASON_LAGGING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Lagging: Self = Self::PROJECTION_UNAVAILABLE_REASON_LAGGING; +} +impl ::core::default::Default for ProjectionUnavailableReason { + fn default() -> Self { + Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for ProjectionUnavailableReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ProjectionUnavailableReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ProjectionUnavailableReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ProjectionUnavailableReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProjectionUnavailableReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ProjectionUnavailableReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some( + Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED, + ) + } + 1i32 => { + ::core::option::Option::Some( + Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING, + ) + } + 2i32 => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_INVALID) + } + 3i32 => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_MISSING) + } + 4i32 => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_LAGGING) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED => { + "PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED" + } + Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING => { + "PROJECTION_UNAVAILABLE_REASON_REBUILDING" + } + Self::PROJECTION_UNAVAILABLE_REASON_INVALID => { + "PROJECTION_UNAVAILABLE_REASON_INVALID" + } + Self::PROJECTION_UNAVAILABLE_REASON_MISSING => { + "PROJECTION_UNAVAILABLE_REASON_MISSING" + } + Self::PROJECTION_UNAVAILABLE_REASON_LAGGING => { + "PROJECTION_UNAVAILABLE_REASON_LAGGING" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED" => { + ::core::option::Option::Some( + Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED, + ) + } + "PROJECTION_UNAVAILABLE_REASON_REBUILDING" => { + ::core::option::Option::Some( + Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING, + ) + } + "PROJECTION_UNAVAILABLE_REASON_INVALID" => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_INVALID) + } + "PROJECTION_UNAVAILABLE_REASON_MISSING" => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_MISSING) + } + "PROJECTION_UNAVAILABLE_REASON_LAGGING" => { + ::core::option::Option::Some(Self::PROJECTION_UNAVAILABLE_REASON_LAGGING) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::PROJECTION_UNAVAILABLE_REASON_UNSPECIFIED, + Self::PROJECTION_UNAVAILABLE_REASON_REBUILDING, + Self::PROJECTION_UNAVAILABLE_REASON_INVALID, + Self::PROJECTION_UNAVAILABLE_REASON_MISSING, + Self::PROJECTION_UNAVAILABLE_REASON_LAGGING, + ] + } +} +/// QueryError is the typed failure payload for every Session query. +/// +/// It is not carried inside a success response. A query either answers or +/// fails, and collapsing the two into one message invites a caller to read a +/// zero-valued success shape as an empty result. On the JSON-RPC-over-NATS +/// binding (ADR#0056) this rides in the error object's `data`; the numeric code +/// assignment is a separate reservation and is deliberately not invented here. +/// +/// `code` is the machine-readable discriminant and the only field a caller +/// should branch on. `message` is for humans and may change at any time without +/// a version bump, so treating it as an API is a bug. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct QueryError { + /// Field 1: `code` + #[serde(rename = "code", with = "::buffa::json_helpers::proto_enum")] + pub code: ::buffa::EnumValue, + /// Human-readable, non-contractual, safe to log. Never parse it. + /// + /// Field 2: `message` + #[serde(rename = "message", with = "::buffa::json_helpers::proto_string")] + pub message: ::buffa::alloc::string::String, + #[serde(flatten)] + pub detail: ::core::option::Option<__buffa::oneof::query_error::Detail>, +} +impl ::core::fmt::Debug for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryError") + .field("code", &self.code) + .field("message", &self.message) + .field("detail", &self.detail) + .finish() + } +} +impl QueryError { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.QueryError"; +} +::buffa::impl_default_instance!(QueryError); +impl ::buffa::MessageName for QueryError { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "QueryError"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.QueryError"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.QueryError"; +} +impl ::buffa::Message for QueryError { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.code.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.message) as u64; + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + __buffa::oneof::query_error::Detail::UnsupportedContractVersion(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::query_error::Detail::StaleCursor(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::query_error::Detail::ProjectionUnavailable(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::query_error::Detail::InvalidArgument(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.code.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.message, buf); + if let ::core::option::Option::Some(ref v) = self.detail { + match v { + __buffa::oneof::query_error::Detail::UnsupportedContractVersion(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::query_error::Detail::StaleCursor(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::query_error::Detail::ProjectionUnavailable(x) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::query_error::Detail::InvalidArgument(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.code = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::UnsupportedContractVersion( + ref mut existing, + ), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::UnsupportedContractVersion( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::StaleCursor(ref mut existing), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::StaleCursor( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::ProjectionUnavailable( + ref mut existing, + ), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::ProjectionUnavailable( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::InvalidArgument( + ref mut existing, + ), + ) = self.detail + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.detail = ::core::option::Option::Some( + __buffa::oneof::query_error::Detail::InvalidArgument( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.code = ::buffa::EnumValue::from(0); + self.message.clear(); + self.detail = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for QueryError { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = QueryError; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct QueryError") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __f_code: ::core::option::Option< + ::buffa::EnumValue, + > = None; + let mut __f_message: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __oneof_detail: ::core::option::Option< + __buffa::oneof::query_error::Detail, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "code" => { + __f_code = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::EnumValue; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::EnumValue, + D::Error, + > { + ::buffa::json_helpers::proto_enum::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "message" => { + __f_message = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "unsupportedContractVersion" + | "unsupported_contract_version" => { + let v: ::core::option::Option< + UnsupportedContractVersionDetail, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + UnsupportedContractVersionDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::query_error::Detail::UnsupportedContractVersion( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "staleCursor" | "stale_cursor" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + StaleCursorDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::query_error::Detail::StaleCursor( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "projectionUnavailable" | "projection_unavailable" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + ProjectionUnavailableDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::query_error::Detail::ProjectionUnavailable( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "invalidArgument" | "invalid_argument" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + InvalidArgumentDetail, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_detail.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'detail'", + ), + ); + } + __oneof_detail = Some( + __buffa::oneof::query_error::Detail::InvalidArgument( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + if let ::core::option::Option::Some(v) = __f_code { + __r.code = v; + } + if let ::core::option::Option::Some(v) = __f_message { + __r.message = v; + } + __r.detail = __oneof_detail; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for QueryError { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __QUERY_ERROR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.QueryError", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod query_error { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::__buffa::oneof::query_error::Detail; + #[doc(inline)] + pub use super::__buffa::view::oneof::query_error::Detail as DetailView; +} +/// UnsupportedContractVersionDetail tells the caller what it would have to +/// speak, so an incompatibility is actionable rather than merely reported. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UnsupportedContractVersionDetail { + /// Field 1: `requested` + #[serde(rename = "requested")] + pub requested: ::buffa::MessageField< + ContractVersion, + ::buffa::Inline, + >, + /// Inclusive range of majors this server can render. + /// + /// Field 2: `supported_major_min` + #[serde( + rename = "supportedMajorMin", + alias = "supported_major_min", + with = "::buffa::json_helpers::uint32" + )] + pub supported_major_min: u32, + /// Field 3: `supported_major_max` + #[serde( + rename = "supportedMajorMax", + alias = "supported_major_max", + with = "::buffa::json_helpers::uint32" + )] + pub supported_major_max: u32, +} +impl ::core::fmt::Debug for UnsupportedContractVersionDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UnsupportedContractVersionDetail") + .field("requested", &self.requested) + .field("supported_major_min", &self.supported_major_min) + .field("supported_major_max", &self.supported_major_max) + .finish() + } +} +impl UnsupportedContractVersionDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail"; +} +::buffa::impl_default_instance!(UnsupportedContractVersionDetail); +impl ::buffa::MessageName for UnsupportedContractVersionDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "UnsupportedContractVersionDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail"; +} +impl ::buffa::Message for UnsupportedContractVersionDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.requested.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.requested.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.supported_major_min) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.supported_major_max) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.requested.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.requested.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(2u32, self.supported_major_min, buf); + ::buffa::types::put_uint32_field(3u32, self.supported_major_max, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.requested.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.supported_major_min = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.supported_major_max = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.requested = ::buffa::MessageField::none(); + self.supported_major_min = 0u32; + self.supported_major_max = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for UnsupportedContractVersionDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UNSUPPORTED_CONTRACT_VERSION_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.UnsupportedContractVersionDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// StaleCursorDetail says why a previously valid cursor stopped being valid, so +/// a caller can tell a benign restart from a view that changed underneath it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StaleCursorDetail { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for StaleCursorDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StaleCursorDetail").field("reason", &self.reason).finish() + } +} +impl StaleCursorDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail"; +} +::buffa::impl_default_instance!(StaleCursorDetail); +impl ::buffa::MessageName for StaleCursorDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "StaleCursorDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail"; +} +impl ::buffa::Message for StaleCursorDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StaleCursorDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STALE_CURSOR_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.StaleCursorDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ProjectionUnavailableDetail distinguishes "come back shortly" from "this is +/// broken", which a caller cannot guess from the code alone. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProjectionUnavailableDetail { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// How current the projection was when it gave up. Present for REASON_LAGGING, + /// where it is the difference between an actionable failure and a bare one: a + /// caller that can see it reached the required position minus two can retry + /// with a larger budget, while one that cannot see it can only guess. + /// + /// Field 2: `freshness` + #[serde( + rename = "freshness", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub freshness: ::buffa::MessageField< + ProjectionFreshness, + ::buffa::Inline, + >, + /// How far along the rebuild is. Present for REASON_REBUILDING when the + /// rebuilder can report it. + /// + /// Without this, "come back shortly" is a claim with no number attached, and a + /// caller has to choose between polling a rebuild that will take four hours + /// and giving up on one that will take four seconds. Absent means the + /// rebuilder could not say, which is different from a rebuild that has made no + /// progress. + /// + /// Field 3: `rebuild` + #[serde( + rename = "rebuild", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub rebuild: ::buffa::MessageField< + RebuildProgress, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ProjectionUnavailableDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProjectionUnavailableDetail") + .field("reason", &self.reason) + .field("freshness", &self.freshness) + .field("rebuild", &self.rebuild) + .finish() + } +} +impl ProjectionUnavailableDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail"; +} +::buffa::impl_default_instance!(ProjectionUnavailableDetail); +impl ::buffa::MessageName for ProjectionUnavailableDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ProjectionUnavailableDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail"; +} +impl ::buffa::Message for ProjectionUnavailableDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.freshness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.freshness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.rebuild.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.rebuild.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if self.freshness.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.freshness.write_to(__cache, buf); + } + if self.rebuild.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.rebuild.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.freshness.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.rebuild.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + self.freshness = ::buffa::MessageField::none(); + self.rebuild = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProjectionUnavailableDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PROJECTION_UNAVAILABLE_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ProjectionUnavailableDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RebuildProgress is how far a projection rebuild has got. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RebuildProgress { + /// Field 1: `started_at` + #[serde(rename = "startedAt", alias = "started_at")] + pub started_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// Position the rebuild has applied through, in the same units the finished + /// projection will report as its processed watermark. + /// + /// Field 2: `processed_watermark` + #[serde( + rename = "processedWatermark", + alias = "processed_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub processed_watermark: u64, + /// Position the rebuild is working toward, as known when it started. + /// + /// Unset when the rebuilder does not know its own end, which is the honest + /// answer for a rebuild over a stream that is still being written to. Reported + /// as unset rather than as the current head, because a target that moves is a + /// percentage that goes backwards. + /// + /// Field 3: `target_watermark` + #[serde( + rename = "targetWatermark", + alias = "target_watermark", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub target_watermark: ::core::option::Option, +} +impl ::core::fmt::Debug for RebuildProgress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RebuildProgress") + .field("started_at", &self.started_at) + .field("processed_watermark", &self.processed_watermark) + .field("target_watermark", &self.target_watermark) + .finish() + } +} +impl RebuildProgress { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RebuildProgress"; +} +impl RebuildProgress { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::target_watermark`] to `Some(value)`, consuming and returning `self`. + pub fn with_target_watermark(mut self, value: u64) -> Self { + self.target_watermark = Some(value); + self + } +} +::buffa::impl_default_instance!(RebuildProgress); +impl ::buffa::MessageName for RebuildProgress { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "RebuildProgress"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.RebuildProgress"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RebuildProgress"; +} +impl ::buffa::Message for RebuildProgress { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if let Some(v) = self.target_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(2u32, self.processed_watermark, buf); + if let Some(v) = self.target_watermark { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.started_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.processed_watermark = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.target_watermark = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.started_at = ::buffa::MessageField::none(); + self.processed_watermark = 0u64; + self.target_watermark = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RebuildProgress { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REBUILD_PROGRESS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RebuildProgress", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// InvalidArgumentDetail names the offending input. It carries a field path +/// rather than a rendered sentence so a caller can map the failure back to its +/// own request structure. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct InvalidArgumentDetail { + /// Dotted path into the request message, for example `page_size`. + /// + /// Field 1: `field_path` + #[serde( + rename = "fieldPath", + alias = "field_path", + with = "::buffa::json_helpers::proto_string" + )] + pub field_path: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for InvalidArgumentDetail { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("InvalidArgumentDetail") + .field("field_path", &self.field_path) + .finish() + } +} +impl InvalidArgumentDetail { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail"; +} +::buffa::impl_default_instance!(InvalidArgumentDetail); +impl ::buffa::MessageName for InvalidArgumentDetail { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "InvalidArgumentDetail"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail"; +} +impl ::buffa::Message for InvalidArgumentDetail { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.field_path) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.field_path, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.field_path, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.field_path.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for InvalidArgumentDetail { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __INVALID_ARGUMENT_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.InvalidArgumentDetail", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.__view.rs new file mode 100644 index 0000000000..72602215d9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.__view.rs @@ -0,0 +1,737 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/read_consistency.proto + +/// ReadConsistency is the freshness the caller requires, declared before the +/// server answers. +/// +/// The case it exists for is read-your-writes. A caller that has just issued a +/// command knows the position its write landed at, and an eventual read of a +/// projection that has not applied it yet returns a view that is correct and +/// wrong at the same time: correct as of the projection, wrong as of what the +/// caller knows to have happened. Redaction is the sharp version, since the view +/// still contains content the caller was told is gone. +/// +/// Every request carries one. Unset is EVENTUAL, which keeps the common read +/// cheap while still reporting freshness on the way back. +#[derive(Clone, Debug, Default)] +pub struct ReadConsistencyView<'a> { + /// Field 1: `mode` + pub mode: ::buffa::EnumValue, + /// Required for MODE_AT_LEAST, ignored otherwise. A MODE_AT_LEAST request with + /// no token is QUERY_ERROR_CODE_INVALID_ARGUMENT rather than a silent + /// downgrade to an eventual read. + /// + /// Field 2: `token` + pub token: ::buffa::MessageFieldView< + super::super::__buffa::view::ConsistencyTokenView<'a>, + >, + /// How long the read may wait for the projection to reach the token. Unset or + /// zero means do not wait: answer if the projection is already there, fail + /// otherwise. + /// + /// The budget is the caller's because only the caller knows whether it is + /// serving an interactive request. A read that cannot be satisfied within it + /// fails with QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE and + /// PROJECTION_UNAVAILABLE_REASON_LAGGING, carrying the freshness it reached so + /// the caller can retry with a larger budget or fall back to an eventual read + /// on purpose. + /// + /// Field 3: `max_wait` + pub max_wait: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReadConsistencyView<'a> { + /**Whether required field `mode` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_mode(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReadConsistencyView<'a> { + type Owned = super::super::ReadConsistency; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.mode = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.token.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.token = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.max_wait.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.max_wait = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReadConsistency { + mode: self.mode, + token: match self.token.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ConsistencyToken, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + max_wait: match self.max_wait.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReadConsistencyView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.token.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.token.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.max_wait.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_wait.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.mode.to_i32(), buf); + if self.token.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.token.write_to(__cache, buf); + } + if self.max_wait.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_wait.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReadConsistencyView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("mode", &self.mode)?; + } + { + if let ::core::option::Option::Some(__v) = self.token.as_option() { + __map.serialize_entry("token", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.max_wait.as_option() { + __map.serialize_entry("maxWait", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReadConsistencyView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ReadConsistency"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ReadConsistency"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ReadConsistency"; +} +::buffa::impl_default_view_instance!(ReadConsistencyView); +::buffa::impl_view_reborrow!(ReadConsistencyView); +/** Self-contained, `'static` owned view of a `ReadConsistency` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReadConsistencyView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReadConsistencyView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReadConsistencyOwnedView(::buffa::OwnedView>); +impl ReadConsistencyOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadConsistencyOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadConsistencyOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReadConsistency, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReadConsistencyOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReadConsistencyView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReadConsistencyView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReadConsistency { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `mode` + #[must_use] + pub fn mode(&self) -> ::buffa::EnumValue { + self.0.reborrow().mode + } + /// Required for MODE_AT_LEAST, ignored otherwise. A MODE_AT_LEAST request with + /// no token is QUERY_ERROR_CODE_INVALID_ARGUMENT rather than a silent + /// downgrade to an eventual read. + /// + /// Field 2: `token` + #[must_use] + pub fn token( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ConsistencyTokenView<'_>, + > { + &self.0.reborrow().token + } + /// How long the read may wait for the projection to reach the token. Unset or + /// zero means do not wait: answer if the projection is already there, fail + /// otherwise. + /// + /// The budget is the caller's because only the caller knows whether it is + /// serving an interactive request. A read that cannot be satisfied within it + /// fails with QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE and + /// PROJECTION_UNAVAILABLE_REASON_LAGGING, carrying the freshness it reached so + /// the caller can retry with a larger budget or fall back to an eventual read + /// on purpose. + /// + /// Field 3: `max_wait` + #[must_use] + pub fn max_wait( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().max_wait + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReadConsistencyOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReadConsistencyOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReadConsistencyOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReadConsistencyOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReadConsistency { + type View<'a> = ReadConsistencyView<'a>; + type ViewHandle = ReadConsistencyOwnedView; +} +impl ::serde::Serialize for ReadConsistencyOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ConsistencyToken names a write the read must reflect. +/// +/// Unlike a page cursor this is a plain typed message, not opaque authenticated +/// bytes, and the difference is deliberate. A cursor names a scan position and +/// is therefore an instruction the server follows, so a forged one is a way to +/// read what the caller should not. A token only ever makes a read wait or fail: +/// the worst a forged one achieves is the caller's own bounded wait followed by +/// a LAGGING error, and it discloses nothing. Paying for a MAC to prevent that +/// would buy nothing and cost every caller the ability to debug its own reads. +/// +/// The write path mints these. The command-response shape that hands one back is +/// not defined yet. +#[derive(Clone, Debug, Default)] +pub struct ConsistencyTokenView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The SessionOrdinal the caller's write landed at. + /// + /// An ordinal rather than a stream sequence, for the same reason page cursors + /// use one: it is fold-derived and reproduces identically on replay, so it + /// survives a projection rebuild. A list read uses this too, since a list + /// projection that consumes many streams still knows how far it has applied + /// each one, and "the list reflects my change to session X" is the only + /// freshness question a caller actually has. + /// + /// Field 2: `session_ordinal` + pub session_ordinal: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ConsistencyTokenView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `session_ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ConsistencyTokenView<'a> { + type Owned = super::super::ConsistencyToken; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.session_ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ConsistencyToken { + session_id: self.session_id.to_string(), + session_ordinal: self.session_ordinal, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ConsistencyTokenView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.session_ordinal) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.session_ordinal, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ConsistencyTokenView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map + .serialize_entry( + "sessionOrdinal", + &::buffa::json_helpers::ProtoJson(&self.session_ordinal), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ConsistencyTokenView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ConsistencyToken"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ConsistencyToken"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyToken"; +} +::buffa::impl_default_view_instance!(ConsistencyTokenView); +::buffa::impl_view_reborrow!(ConsistencyTokenView); +/** Self-contained, `'static` owned view of a `ConsistencyToken` message. + + Wraps [`::buffa::OwnedView`]`<`[`ConsistencyTokenView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ConsistencyTokenView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ConsistencyTokenOwnedView(::buffa::OwnedView>); +impl ConsistencyTokenOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyTokenOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyTokenOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ConsistencyToken, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsistencyTokenOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ConsistencyTokenView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ConsistencyTokenView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ConsistencyToken { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The SessionOrdinal the caller's write landed at. + /// + /// An ordinal rather than a stream sequence, for the same reason page cursors + /// use one: it is fold-derived and reproduces identically on replay, so it + /// survives a projection rebuild. A list read uses this too, since a list + /// projection that consumes many streams still knows how far it has applied + /// each one, and "the list reflects my change to session X" is the only + /// freshness question a caller actually has. + /// + /// Field 2: `session_ordinal` + #[must_use] + pub fn session_ordinal(&self) -> u64 { + self.0.reborrow().session_ordinal + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ConsistencyTokenOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ConsistencyTokenOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ConsistencyTokenOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ConsistencyTokenOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ConsistencyToken { + type View<'a> = ConsistencyTokenView<'a>; + type ViewHandle = ConsistencyTokenOwnedView; +} +impl ::serde::Serialize for ConsistencyTokenOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.rs new file mode 100644 index 0000000000..ae6b085462 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.read_consistency.rs @@ -0,0 +1,517 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/read_consistency.proto + +/// ReadConsistencyMode is how strictly the read is bound to a known write. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ReadConsistencyMode { + /// Treated as EVENTUAL. Unset is the ordinary case, not an error, because + /// most reads have no write to be consistent with. + READ_CONSISTENCY_MODE_UNSPECIFIED = 0i32, + /// Serve whatever the projection has applied. Freshness is still reported. + READ_CONSISTENCY_MODE_EVENTUAL = 1i32, + /// Serve only once the projection has applied `token`. + READ_CONSISTENCY_MODE_AT_LEAST = 2i32, +} +impl ReadConsistencyMode { + ///Idiomatic alias for [`Self::READ_CONSISTENCY_MODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::READ_CONSISTENCY_MODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::READ_CONSISTENCY_MODE_EVENTUAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Eventual: Self = Self::READ_CONSISTENCY_MODE_EVENTUAL; + ///Idiomatic alias for [`Self::READ_CONSISTENCY_MODE_AT_LEAST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AtLeast: Self = Self::READ_CONSISTENCY_MODE_AT_LEAST; +} +impl ::core::default::Default for ReadConsistencyMode { + fn default() -> Self { + Self::READ_CONSISTENCY_MODE_UNSPECIFIED + } +} +impl ::serde::Serialize for ReadConsistencyMode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ReadConsistencyMode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ReadConsistencyMode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ReadConsistencyMode) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReadConsistencyMode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ReadConsistencyMode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_EVENTUAL), + 2i32 => ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_AT_LEAST), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::READ_CONSISTENCY_MODE_UNSPECIFIED => { + "READ_CONSISTENCY_MODE_UNSPECIFIED" + } + Self::READ_CONSISTENCY_MODE_EVENTUAL => "READ_CONSISTENCY_MODE_EVENTUAL", + Self::READ_CONSISTENCY_MODE_AT_LEAST => "READ_CONSISTENCY_MODE_AT_LEAST", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "READ_CONSISTENCY_MODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_UNSPECIFIED) + } + "READ_CONSISTENCY_MODE_EVENTUAL" => { + ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_EVENTUAL) + } + "READ_CONSISTENCY_MODE_AT_LEAST" => { + ::core::option::Option::Some(Self::READ_CONSISTENCY_MODE_AT_LEAST) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::READ_CONSISTENCY_MODE_UNSPECIFIED, + Self::READ_CONSISTENCY_MODE_EVENTUAL, + Self::READ_CONSISTENCY_MODE_AT_LEAST, + ] + } +} +/// ReadConsistency is the freshness the caller requires, declared before the +/// server answers. +/// +/// The case it exists for is read-your-writes. A caller that has just issued a +/// command knows the position its write landed at, and an eventual read of a +/// projection that has not applied it yet returns a view that is correct and +/// wrong at the same time: correct as of the projection, wrong as of what the +/// caller knows to have happened. Redaction is the sharp version, since the view +/// still contains content the caller was told is gone. +/// +/// Every request carries one. Unset is EVENTUAL, which keeps the common read +/// cheap while still reporting freshness on the way back. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReadConsistency { + /// Field 1: `mode` + #[serde(rename = "mode", with = "::buffa::json_helpers::proto_enum")] + pub mode: ::buffa::EnumValue, + /// Required for MODE_AT_LEAST, ignored otherwise. A MODE_AT_LEAST request with + /// no token is QUERY_ERROR_CODE_INVALID_ARGUMENT rather than a silent + /// downgrade to an eventual read. + /// + /// Field 2: `token` + #[serde( + rename = "token", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub token: ::buffa::MessageField< + ConsistencyToken, + ::buffa::Inline, + >, + /// How long the read may wait for the projection to reach the token. Unset or + /// zero means do not wait: answer if the projection is already there, fail + /// otherwise. + /// + /// The budget is the caller's because only the caller knows whether it is + /// serving an interactive request. A read that cannot be satisfied within it + /// fails with QUERY_ERROR_CODE_PROJECTION_UNAVAILABLE and + /// PROJECTION_UNAVAILABLE_REASON_LAGGING, carrying the freshness it reached so + /// the caller can retry with a larger budget or fall back to an eventual read + /// on purpose. + /// + /// Field 3: `max_wait` + #[serde( + rename = "maxWait", + alias = "max_wait", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub max_wait: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for ReadConsistency { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReadConsistency") + .field("mode", &self.mode) + .field("token", &self.token) + .field("max_wait", &self.max_wait) + .finish() + } +} +impl ReadConsistency { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ReadConsistency"; +} +::buffa::impl_default_instance!(ReadConsistency); +impl ::buffa::MessageName for ReadConsistency { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ReadConsistency"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ReadConsistency"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ReadConsistency"; +} +impl ::buffa::Message for ReadConsistency { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.token.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.token.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.max_wait.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_wait.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.mode.to_i32(), buf); + if self.token.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.token.write_to(__cache, buf); + } + if self.max_wait.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_wait.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.mode = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.token.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.max_wait.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.mode = ::buffa::EnumValue::from(0); + self.token = ::buffa::MessageField::none(); + self.max_wait = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReadConsistency { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __READ_CONSISTENCY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ReadConsistency", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ConsistencyToken names a write the read must reflect. +/// +/// Unlike a page cursor this is a plain typed message, not opaque authenticated +/// bytes, and the difference is deliberate. A cursor names a scan position and +/// is therefore an instruction the server follows, so a forged one is a way to +/// read what the caller should not. A token only ever makes a read wait or fail: +/// the worst a forged one achieves is the caller's own bounded wait followed by +/// a LAGGING error, and it discloses nothing. Paying for a MAC to prevent that +/// would buy nothing and cost every caller the ability to debug its own reads. +/// +/// The write path mints these. The command-response shape that hands one back is +/// not defined yet. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ConsistencyToken { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The SessionOrdinal the caller's write landed at. + /// + /// An ordinal rather than a stream sequence, for the same reason page cursors + /// use one: it is fold-derived and reproduces identically on replay, so it + /// survives a projection rebuild. A list read uses this too, since a list + /// projection that consumes many streams still knows how far it has applied + /// each one, and "the list reflects my change to session X" is the only + /// freshness question a caller actually has. + /// + /// Field 2: `session_ordinal` + #[serde( + rename = "sessionOrdinal", + alias = "session_ordinal", + with = "::buffa::json_helpers::uint64" + )] + pub session_ordinal: u64, +} +impl ::core::fmt::Debug for ConsistencyToken { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConsistencyToken") + .field("session_id", &self.session_id) + .field("session_ordinal", &self.session_ordinal) + .finish() + } +} +impl ConsistencyToken { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyToken"; +} +::buffa::impl_default_instance!(ConsistencyToken); +impl ::buffa::MessageName for ConsistencyToken { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ConsistencyToken"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ConsistencyToken"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyToken"; +} +impl ::buffa::Message for ConsistencyToken { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.session_ordinal) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.session_ordinal, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.session_ordinal = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.session_ordinal = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConsistencyToken { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONSISTENCY_TOKEN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ConsistencyToken", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.__view.rs new file mode 100644 index 0000000000..6262d2ff03 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.__view.rs @@ -0,0 +1,3889 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/session_view.proto + +/// SessionSummary is the list-row shape: enough to render a picker, and no more. +/// +/// It deliberately excludes anything requiring a per-session fan-out to compute, +/// because a list query that costs one read per row stops being a list query. +#[derive(Clone, Debug, Default)] +pub struct SessionSummaryView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `lifecycle` + pub lifecycle: ::buffa::EnumValue, + /// Unset while the session is active. + /// + /// Field 3: `terminal_reason` + pub terminal_reason: ::core::option::Option< + ::buffa::EnumValue, + >, + /// Display name, resolved by the precedence on TitleSource. Always set: when + /// there is nothing to show it holds a server-chosen fallback rather than an + /// empty string, so a picker never has to invent one and two clients never + /// invent different ones. + /// + /// Field 4: `title` + pub title: &'a str, + /// Field 5: `title_source` + pub title_source: ::buffa::EnumValue, + /// Field 6: `workspace_id` + pub workspace_id: &'a str, + /// Field 7: `archived` + pub archived: bool, + /// Effective history length in SessionOrdinals, after rewind masking. A caller + /// must not treat this as a count of decodable history items: redaction can + /// mask an ordinal without removing it. + /// + /// Field 8: `effective_length` + pub effective_length: u64, + /// Set when this session is a copy salvaged from a damaged one. On the list row + /// and not only the detail view, because a picker that renders a salvaged + /// session identically to an intact one is where the substitution actually + /// happens: by the time a user opens it they have already decided it is theirs. + /// + /// Field 9: `recovery` + pub recovery: ::buffa::MessageFieldView< + super::super::__buffa::view::RecoveryProvenanceViewView<'a>, + >, + /// Short excerpt of the session's opening content. Always set, including when + /// there is nothing to preview, because the reason there is nothing is itself + /// what a caller needs in order to render the row honestly. + /// + /// Field 10: `preview` + pub preview: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionPreviewView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SessionSummaryView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `lifecycle` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_lifecycle(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `title` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_title(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `title_source` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_title_source(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `workspace_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace_id(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `archived` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_archived(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } + /**Whether required field `effective_length` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_effective_length(&self) -> bool { + self.__buffa_required_seen_0 & 64u64 != 0 + } + /**Whether required field `preview` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_preview(&self) -> bool { + self.preview.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SessionSummaryView<'a> { + type Owned = super::super::SessionSummary; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.lifecycle = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.terminal_reason = Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(&mut cur)?), + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.title = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.title_source = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.workspace_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.archived = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.effective_length = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 64u64; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.recovery.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.recovery = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.preview.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.preview = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionSummary { + session_id: self.session_id.to_string(), + lifecycle: self.lifecycle, + terminal_reason: self.terminal_reason, + title: self.title.to_string(), + title_source: self.title_source, + workspace_id: self.workspace_id.to_string(), + archived: self.archived, + effective_length: self.effective_length, + recovery: match self.recovery.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::RecoveryProvenanceView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + preview: match self.preview.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionPreview, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionSummaryView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.lifecycle.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.terminal_reason { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.title) as u64; + { + let val = self.title_source.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.workspace_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.effective_length) as u64; + if self.recovery.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.recovery.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.preview.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.preview.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.lifecycle.to_i32(), buf); + if let Some(ref v) = self.terminal_reason { + ::buffa::types::put_int32_field(3u32, v.to_i32(), buf); + } + ::buffa::types::put_string_field(4u32, &self.title, buf); + ::buffa::types::put_int32_field(5u32, self.title_source.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.workspace_id, buf); + ::buffa::types::put_bool_field(7u32, self.archived, buf); + ::buffa::types::put_uint64_field(8u32, self.effective_length, buf); + if self.recovery.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.recovery.write_to(__cache, buf); + } + if self.preview.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.preview.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionSummaryView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("lifecycle", &self.lifecycle)?; + } + if let ::core::option::Option::Some(ref __v) = self.terminal_reason { + __map.serialize_entry("terminalReason", __v)?; + } + { + __map.serialize_entry("title", self.title)?; + } + { + __map.serialize_entry("titleSource", &self.title_source)?; + } + { + __map.serialize_entry("workspaceId", self.workspace_id)?; + } + { + __map.serialize_entry("archived", &self.archived)?; + } + { + __map + .serialize_entry( + "effectiveLength", + &::buffa::json_helpers::ProtoJson(&self.effective_length), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.recovery.as_option() { + __map.serialize_entry("recovery", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.preview.as_option() { + __map.serialize_entry("preview", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionSummaryView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionSummary"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionSummary"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionSummary"; +} +::buffa::impl_default_view_instance!(SessionSummaryView); +::buffa::impl_view_reborrow!(SessionSummaryView); +/** Self-contained, `'static` owned view of a `SessionSummary` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionSummaryView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionSummaryView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionSummaryOwnedView(::buffa::OwnedView>); +impl SessionSummaryOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionSummaryOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionSummaryOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionSummary, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionSummaryOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionSummaryView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionSummaryView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionSummary { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `lifecycle` + #[must_use] + pub fn lifecycle(&self) -> ::buffa::EnumValue { + self.0.reborrow().lifecycle + } + /// Unset while the session is active. + /// + /// Field 3: `terminal_reason` + #[must_use] + pub fn terminal_reason( + &self, + ) -> ::core::option::Option<::buffa::EnumValue> { + self.0.reborrow().terminal_reason + } + /// Display name, resolved by the precedence on TitleSource. Always set: when + /// there is nothing to show it holds a server-chosen fallback rather than an + /// empty string, so a picker never has to invent one and two clients never + /// invent different ones. + /// + /// Field 4: `title` + #[must_use] + pub fn title(&self) -> &'_ str { + self.0.reborrow().title + } + /// Field 5: `title_source` + #[must_use] + pub fn title_source(&self) -> ::buffa::EnumValue { + self.0.reborrow().title_source + } + /// Field 6: `workspace_id` + #[must_use] + pub fn workspace_id(&self) -> &'_ str { + self.0.reborrow().workspace_id + } + /// Field 7: `archived` + #[must_use] + pub fn archived(&self) -> bool { + self.0.reborrow().archived + } + /// Effective history length in SessionOrdinals, after rewind masking. A caller + /// must not treat this as a count of decodable history items: redaction can + /// mask an ordinal without removing it. + /// + /// Field 8: `effective_length` + #[must_use] + pub fn effective_length(&self) -> u64 { + self.0.reborrow().effective_length + } + /// Set when this session is a copy salvaged from a damaged one. On the list row + /// and not only the detail view, because a picker that renders a salvaged + /// session identically to an intact one is where the substitution actually + /// happens: by the time a user opens it they have already decided it is theirs. + /// + /// Field 9: `recovery` + #[must_use] + pub fn recovery( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::RecoveryProvenanceViewView<'_>, + > { + &self.0.reborrow().recovery + } + /// Short excerpt of the session's opening content. Always set, including when + /// there is nothing to preview, because the reason there is nothing is itself + /// what a caller needs in order to render the row honestly. + /// + /// Field 10: `preview` + #[must_use] + pub fn preview( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionPreviewView<'_>, + > { + &self.0.reborrow().preview + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionSummaryOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionSummaryOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionSummaryOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionSummaryOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionSummary { + type View<'a> = SessionSummaryView<'a>; + type ViewHandle = SessionSummaryOwnedView; +} +impl ::serde::Serialize for SessionSummaryOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SessionPreview is the excerpt shown beneath a session's title. +/// +/// It is derived from effective history, which is what makes it a projection +/// concern rather than a stored string. Rewind masks ordinals, redaction removes +/// content from ordinals that remain, and either can take away the very message a +/// preview was cut from. A preview cached without regard for that is the case +/// where deliberately destroyed text reappears on a screen, which is a privacy +/// failure and not a staleness annoyance. +/// +/// Its validity therefore tracks `effective_history_revision` and +/// `privacy_revision`, the same two coordinates a presentation cache binds +/// against. A cached preview whose binding fails those two must be discarded, not +/// shown as merely older. +#[derive(Clone, Debug, Default)] +pub struct SessionPreviewView<'a> { + /// The excerpt, truncated at a server-chosen bound. Empty for every + /// availability other than SESSION_PREVIEW_AVAILABILITY_AVAILABLE. + /// + /// Field 1: `text` + pub text: &'a str, + /// Field 2: `availability` + pub availability: ::buffa::EnumValue, + /// True when the excerpt is shorter than the content it came from, so a + /// renderer can mark the cut rather than presenting a fragment as a whole + /// message. + /// + /// Field 3: `truncated` + pub truncated: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SessionPreviewView<'a> { + /**Whether required field `text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_text(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `availability` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_availability(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `truncated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_truncated(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SessionPreviewView<'a> { + type Owned = super::super::SessionPreview; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.truncated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionPreview { + text: self.text.to_string(), + availability: self.availability, + truncated: self.truncated, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionPreviewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.text, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionPreviewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("text", self.text)?; + } + { + __map.serialize_entry("availability", &self.availability)?; + } + { + __map.serialize_entry("truncated", &self.truncated)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionPreviewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionPreview"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionPreview"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionPreview"; +} +::buffa::impl_default_view_instance!(SessionPreviewView); +::buffa::impl_view_reborrow!(SessionPreviewView); +/** Self-contained, `'static` owned view of a `SessionPreview` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionPreviewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionPreviewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionPreviewOwnedView(::buffa::OwnedView>); +impl SessionPreviewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionPreviewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionPreviewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionPreview, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionPreviewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionPreviewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionPreviewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionPreview { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The excerpt, truncated at a server-chosen bound. Empty for every + /// availability other than SESSION_PREVIEW_AVAILABILITY_AVAILABLE. + /// + /// Field 1: `text` + #[must_use] + pub fn text(&self) -> &'_ str { + self.0.reborrow().text + } + /// Field 2: `availability` + #[must_use] + pub fn availability( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().availability + } + /// True when the excerpt is shorter than the content it came from, so a + /// renderer can mark the cut rather than presenting a fragment as a whole + /// message. + /// + /// Field 3: `truncated` + #[must_use] + pub fn truncated(&self) -> bool { + self.0.reborrow().truncated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionPreviewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionPreviewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionPreviewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionPreviewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionPreview { + type View<'a> = SessionPreviewView<'a>; + type ViewHandle = SessionPreviewOwnedView; +} +impl ::serde::Serialize for SessionPreviewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RecoveryProvenanceView marks a session that was salvaged rather than lived. +/// +/// Unset is the ordinary case. When set, a reader must not present the session as +/// the source: it has a different id, its ordinals are its own, and a partial +/// recovery is missing content the original had. +#[derive(Clone, Debug, Default)] +pub struct RecoveryProvenanceViewView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// Field 2: `completeness` + pub completeness: ::buffa::EnumValue, + /// How many source items the salvage could not carry. The enumeration is an + /// operator-side record and is deliberately not on the read contract: a client + /// needs to know the session is incomplete, not to render a damage report. + /// + /// Field 3: `omitted_count` + pub omitted_count: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecoveryProvenanceViewView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `completeness` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `omitted_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_omitted_count(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecoveryProvenanceViewView<'a> { + type Owned = super::super::RecoveryProvenanceView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.omitted_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RecoveryProvenanceView, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RecoveryProvenanceView, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecoveryProvenanceView { + source_session_id: self.source_session_id.to_string(), + completeness: self.completeness, + omitted_count: self.omitted_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecoveryProvenanceViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_int32_field(2u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(3u32, self.omitted_count, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecoveryProvenanceViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + __map.serialize_entry("completeness", &self.completeness)?; + } + { + __map + .serialize_entry( + "omittedCount", + &::buffa::json_helpers::ProtoJson(&self.omitted_count), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecoveryProvenanceViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "RecoveryProvenanceView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView"; +} +::buffa::impl_default_view_instance!(RecoveryProvenanceViewView); +::buffa::impl_view_reborrow!(RecoveryProvenanceViewView); +/** Self-contained, `'static` owned view of a `RecoveryProvenanceView` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecoveryProvenanceViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecoveryProvenanceViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecoveryProvenanceViewOwnedView( + ::buffa::OwnedView>, +); +impl RecoveryProvenanceViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryProvenanceViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryProvenanceViewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecoveryProvenanceView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryProvenanceViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecoveryProvenanceViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecoveryProvenanceViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecoveryProvenanceView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// Field 2: `completeness` + #[must_use] + pub fn completeness( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().completeness + } + /// How many source items the salvage could not carry. The enumeration is an + /// operator-side record and is deliberately not on the read contract: a client + /// needs to know the session is incomplete, not to render a damage report. + /// + /// Field 3: `omitted_count` + #[must_use] + pub fn omitted_count(&self) -> u32 { + self.0.reborrow().omitted_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecoveryProvenanceViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecoveryProvenanceViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecoveryProvenanceViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecoveryProvenanceViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecoveryProvenanceView { + type View<'a> = RecoveryProvenanceViewView<'a>; + type ViewHandle = RecoveryProvenanceViewOwnedView; +} +impl ::serde::Serialize for RecoveryProvenanceViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SessionView is the detail shape returned by GetSession. +/// +/// It reports lifecycle and shape, never the transcript. History is a separate, +/// paginated query because a session's history has no bound and a detail read +/// that inlines it has no bound either. +#[derive(Clone, Debug, Default)] +pub struct SessionViewView<'a> { + /// Field 1: `summary` + pub summary: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionSummaryView<'a>, + >, + /// Set when this session was forked from another. + /// + /// Field 2: `fork_origin` + pub fork_origin: ::buffa::MessageFieldView< + super::super::__buffa::view::ForkOriginViewView<'a>, + >, + /// Set when this session was dispatched by a parent. + /// + /// Field 3: `parent` + pub parent: ::buffa::MessageFieldView< + super::super::__buffa::view::ParentViewView<'a>, + >, + /// Sessions this one dispatched, parent side. + /// + /// Field 4: `delegations` + pub delegations: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::DelegationViewView<'a>, + >, + /// True when at least one tool call has started with no terminal outcome, or + /// at least one reserved operation is unsettled. This is the reader-visible + /// form of "something needs reconciling"; a caller must not conclude a session + /// is complete from a terminal lifecycle alone. + /// + /// Field 5: `has_unreconciled_work` + pub has_unreconciled_work: bool, + /// How much of this session's artifact content is still retrievable. Always + /// set, including when everything is intact, so a caller never has to read an + /// absent field as good news. + /// + /// Field 6: `artifacts` + pub artifacts: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactCompletenessViewView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SessionViewView<'a> { + /**Whether required field `summary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary(&self) -> bool { + self.summary.is_set() + } + /**Whether required field `has_unreconciled_work` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_has_unreconciled_work(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifacts` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifacts(&self) -> bool { + self.artifacts.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SessionViewView<'a> { + type Owned = super::super::SessionView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.summary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.summary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.fork_origin.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.fork_origin = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.parent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.parent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.has_unreconciled_work = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.artifacts.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.artifacts = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::DelegationViewView, + >(), + )?; + view.delegations + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionView { + summary: match self.summary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionSummary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + fork_origin: match self.fork_origin.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ForkOriginView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + parent: match self.parent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ParentView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + delegations: self + .delegations + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + has_unreconciled_work: self.has_unreconciled_work, + artifacts: match self.artifacts.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactCompletenessView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.summary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.summary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.fork_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fork_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.parent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.delegations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.artifacts.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifacts.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.summary.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.summary.write_to(__cache, buf); + } + if self.fork_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.fork_origin.write_to(__cache, buf); + } + if self.parent.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent.write_to(__cache, buf); + } + for v in &self.delegations { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(5u32, self.has_unreconciled_work, buf); + if self.artifacts.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifacts.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.summary.as_option() { + __map.serialize_entry("summary", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.fork_origin.as_option() { + __map.serialize_entry("forkOrigin", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.parent.as_option() { + __map.serialize_entry("parent", __v)?; + } + } + if !self.delegations.is_empty() { + __map.serialize_entry("delegations", &*self.delegations)?; + } + { + __map.serialize_entry("hasUnreconciledWork", &self.has_unreconciled_work)?; + } + { + if let ::core::option::Option::Some(__v) = self.artifacts.as_option() { + __map.serialize_entry("artifacts", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionView"; +} +::buffa::impl_default_view_instance!(SessionViewView); +::buffa::impl_view_reborrow!(SessionViewView); +/** Self-contained, `'static` owned view of a `SessionView` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionViewOwnedView(::buffa::OwnedView>); +impl SessionViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionViewOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `summary` + #[must_use] + pub fn summary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionSummaryView<'_>, + > { + &self.0.reborrow().summary + } + /// Set when this session was forked from another. + /// + /// Field 2: `fork_origin` + #[must_use] + pub fn fork_origin( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ForkOriginViewView<'_>, + > { + &self.0.reborrow().fork_origin + } + /// Set when this session was dispatched by a parent. + /// + /// Field 3: `parent` + #[must_use] + pub fn parent( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().parent + } + /// Sessions this one dispatched, parent side. + /// + /// Field 4: `delegations` + #[must_use] + pub fn delegations( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::DelegationViewView<'_>, + > { + &self.0.reborrow().delegations + } + /// True when at least one tool call has started with no terminal outcome, or + /// at least one reserved operation is unsettled. This is the reader-visible + /// form of "something needs reconciling"; a caller must not conclude a session + /// is complete from a terminal lifecycle alone. + /// + /// Field 5: `has_unreconciled_work` + #[must_use] + pub fn has_unreconciled_work(&self) -> bool { + self.0.reborrow().has_unreconciled_work + } + /// How much of this session's artifact content is still retrievable. Always + /// set, including when everything is intact, so a caller never has to read an + /// absent field as good news. + /// + /// Field 6: `artifacts` + #[must_use] + pub fn artifacts( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactCompletenessViewView<'_>, + > { + &self.0.reborrow().artifacts + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionView { + type View<'a> = SessionViewView<'a>; + type ViewHandle = SessionViewOwnedView; +} +impl ::serde::Serialize for SessionViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ArtifactCompletenessView is how complete this session's artifact content is, +/// reported separately from its lifecycle. +/// +/// The two are independent and routinely disagree. A session can close having +/// done exactly what was asked and still be missing the output it produced, +/// because artifact bytes live outside the log and outlive nothing in +/// particular: they get erased under a retention policy, or under a deletion +/// request, or by a storage fault. A reader that infers retrievability from +/// TERMINAL_REASON_CLOSED will present an empty result as a successful one. +/// +/// This rollup counts only what the log itself establishes. Whether the bytes an +/// intact claim-check points to are actually there is a fact about an external +/// store, and learning it costs one probe per artifact, which is not something a +/// list or detail query can do and remain a query. That answer arrives through +/// `observed` when someone has gone and looked. +#[derive(Clone, Debug, Default)] +pub struct ArtifactCompletenessViewView<'a> { + /// Artifacts recorded on this session's effective history. Rewind-masked and + /// redacted ordinals contribute nothing, so this counts what the caller can + /// see referenced rather than everything ever recorded. + /// + /// Field 1: `recorded` + pub recorded: u32, + /// Recorded with durably stored bytes and no erasure since. This is the count + /// the log supports; it is a claim about what was promised, not about what a + /// store would return right now. + /// + /// Field 2: `claimed_retrievable` + pub claimed_retrievable: u32, + /// Destroyed on purpose, recorded by ArtifactErased. Counted apart from every + /// other absence because it is the one that is working as intended. + /// + /// Field 3: `erased` + pub erased: u32, + /// Recorded as an external reference whose bytes were never durably stored. + /// Nothing was lost; nothing was ever held. + /// + /// Field 4: `external_only` + pub external_only: u32, + /// Referenced by this session and not readable by this caller. Per-caller, so + /// two readers of the same session can see different totals, and the point of + /// surfacing it is that the difference is authorization rather than damage. + /// + /// Field 5: `hidden` + pub hidden: u32, + /// Set only when the artifact store has actually been checked for this + /// session. Unset means nobody has looked, which is not the same as nothing + /// being wrong, and the field is absent rather than zeroed so the two cannot + /// be confused. + /// + /// Field 6: `observed` + pub observed: ::buffa::MessageFieldView< + super::super::__buffa::view::ObservedIntegrityViewView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ArtifactCompletenessViewView<'a> { + /**Whether required field `recorded` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_recorded(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `claimed_retrievable` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_claimed_retrievable(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `erased` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_erased(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `external_only` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_external_only(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `hidden` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_hidden(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ArtifactCompletenessViewView<'a> { + type Owned = super::super::ArtifactCompletenessView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.recorded = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.claimed_retrievable = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.erased = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.external_only = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.hidden = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ArtifactCompletenessView, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ArtifactCompletenessView, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ArtifactCompletenessView { + recorded: self.recorded, + claimed_retrievable: self.claimed_retrievable, + erased: self.erased, + external_only: self.external_only, + hidden: self.hidden, + observed: match self.observed.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ObservedIntegrityView, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ArtifactCompletenessViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.recorded) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.claimed_retrievable) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.erased) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.external_only) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.hidden) as u64; + if self.observed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.recorded, buf); + ::buffa::types::put_uint32_field(2u32, self.claimed_retrievable, buf); + ::buffa::types::put_uint32_field(3u32, self.erased, buf); + ::buffa::types::put_uint32_field(4u32, self.external_only, buf); + ::buffa::types::put_uint32_field(5u32, self.hidden, buf); + if self.observed.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ArtifactCompletenessViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "recorded", + &::buffa::json_helpers::ProtoJson(&self.recorded), + )?; + } + { + __map + .serialize_entry( + "claimedRetrievable", + &::buffa::json_helpers::ProtoJson(&self.claimed_retrievable), + )?; + } + { + __map + .serialize_entry( + "erased", + &::buffa::json_helpers::ProtoJson(&self.erased), + )?; + } + { + __map + .serialize_entry( + "externalOnly", + &::buffa::json_helpers::ProtoJson(&self.external_only), + )?; + } + { + __map + .serialize_entry( + "hidden", + &::buffa::json_helpers::ProtoJson(&self.hidden), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.observed.as_option() { + __map.serialize_entry("observed", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ArtifactCompletenessViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ArtifactCompletenessView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView"; +} +::buffa::impl_default_view_instance!(ArtifactCompletenessViewView); +::buffa::impl_view_reborrow!(ArtifactCompletenessViewView); +/** Self-contained, `'static` owned view of a `ArtifactCompletenessView` message. + + Wraps [`::buffa::OwnedView`]`<`[`ArtifactCompletenessViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ArtifactCompletenessViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ArtifactCompletenessViewOwnedView( + ::buffa::OwnedView>, +); +impl ArtifactCompletenessViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactCompletenessViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactCompletenessViewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ArtifactCompletenessView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArtifactCompletenessViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ArtifactCompletenessViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ArtifactCompletenessViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ArtifactCompletenessView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Artifacts recorded on this session's effective history. Rewind-masked and + /// redacted ordinals contribute nothing, so this counts what the caller can + /// see referenced rather than everything ever recorded. + /// + /// Field 1: `recorded` + #[must_use] + pub fn recorded(&self) -> u32 { + self.0.reborrow().recorded + } + /// Recorded with durably stored bytes and no erasure since. This is the count + /// the log supports; it is a claim about what was promised, not about what a + /// store would return right now. + /// + /// Field 2: `claimed_retrievable` + #[must_use] + pub fn claimed_retrievable(&self) -> u32 { + self.0.reborrow().claimed_retrievable + } + /// Destroyed on purpose, recorded by ArtifactErased. Counted apart from every + /// other absence because it is the one that is working as intended. + /// + /// Field 3: `erased` + #[must_use] + pub fn erased(&self) -> u32 { + self.0.reborrow().erased + } + /// Recorded as an external reference whose bytes were never durably stored. + /// Nothing was lost; nothing was ever held. + /// + /// Field 4: `external_only` + #[must_use] + pub fn external_only(&self) -> u32 { + self.0.reborrow().external_only + } + /// Referenced by this session and not readable by this caller. Per-caller, so + /// two readers of the same session can see different totals, and the point of + /// surfacing it is that the difference is authorization rather than damage. + /// + /// Field 5: `hidden` + #[must_use] + pub fn hidden(&self) -> u32 { + self.0.reborrow().hidden + } + /// Set only when the artifact store has actually been checked for this + /// session. Unset means nobody has looked, which is not the same as nothing + /// being wrong, and the field is absent rather than zeroed so the two cannot + /// be confused. + /// + /// Field 6: `observed` + #[must_use] + pub fn observed( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ObservedIntegrityViewView<'_>, + > { + &self.0.reborrow().observed + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ArtifactCompletenessViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ArtifactCompletenessViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ArtifactCompletenessViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ArtifactCompletenessViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ArtifactCompletenessView { + type View<'a> = ArtifactCompletenessViewView<'a>; + type ViewHandle = ArtifactCompletenessViewOwnedView; +} +impl ::serde::Serialize for ArtifactCompletenessViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ObservedIntegrityView is what a probe of the artifact store found, and when. +/// +/// These counts age. They describe a store at the instant it was read, and an +/// artifact can be lost the moment after; `observed_at` is here so a caller can +/// decide whether the answer is still worth acting on rather than treating a +/// stale all-clear as a current one. +#[derive(Clone, Debug, Default)] +pub struct ObservedIntegrityViewView<'a> { + /// Claim-checks the store had no object for, with no erasure recorded. This is + /// the count that means data was lost. + /// + /// Field 1: `missing` + pub missing: u32, + /// Objects present whose content does not match the digest on the log. + /// + /// Field 2: `digest_mismatch` + pub digest_mismatch: u32, + /// Objects that could not be read at all, which makes no claim about whether + /// they exist. Counted apart from `missing` because a transport or permissions + /// fault reported as data loss sends an operator looking for a backup instead + /// of a broken credential. + /// + /// Field 3: `unreadable` + pub unreadable: u32, + /// Field 4: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ObservedIntegrityViewView<'a> { + /**Whether required field `missing` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_missing(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `digest_mismatch` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_digest_mismatch(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `unreadable` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_unreadable(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ObservedIntegrityViewView<'a> { + type Owned = super::super::ObservedIntegrityView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.missing = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.digest_mismatch = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.unreadable = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ObservedIntegrityView, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ObservedIntegrityView, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ObservedIntegrityView { + missing: self.missing, + digest_mismatch: self.digest_mismatch, + unreadable: self.unreadable, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ObservedIntegrityViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.missing) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.digest_mismatch) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unreadable) as u64; + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.missing, buf); + ::buffa::types::put_uint32_field(2u32, self.digest_mismatch, buf); + ::buffa::types::put_uint32_field(3u32, self.unreadable, buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ObservedIntegrityViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "missing", + &::buffa::json_helpers::ProtoJson(&self.missing), + )?; + } + { + __map + .serialize_entry( + "digestMismatch", + &::buffa::json_helpers::ProtoJson(&self.digest_mismatch), + )?; + } + { + __map + .serialize_entry( + "unreadable", + &::buffa::json_helpers::ProtoJson(&self.unreadable), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ObservedIntegrityViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ObservedIntegrityView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView"; +} +::buffa::impl_default_view_instance!(ObservedIntegrityViewView); +::buffa::impl_view_reborrow!(ObservedIntegrityViewView); +/** Self-contained, `'static` owned view of a `ObservedIntegrityView` message. + + Wraps [`::buffa::OwnedView`]`<`[`ObservedIntegrityViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ObservedIntegrityViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ObservedIntegrityViewOwnedView( + ::buffa::OwnedView>, +); +impl ObservedIntegrityViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ObservedIntegrityViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ObservedIntegrityViewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ObservedIntegrityView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ObservedIntegrityViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ObservedIntegrityViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ObservedIntegrityViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ObservedIntegrityView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Claim-checks the store had no object for, with no erasure recorded. This is + /// the count that means data was lost. + /// + /// Field 1: `missing` + #[must_use] + pub fn missing(&self) -> u32 { + self.0.reborrow().missing + } + /// Objects present whose content does not match the digest on the log. + /// + /// Field 2: `digest_mismatch` + #[must_use] + pub fn digest_mismatch(&self) -> u32 { + self.0.reborrow().digest_mismatch + } + /// Objects that could not be read at all, which makes no claim about whether + /// they exist. Counted apart from `missing` because a transport or permissions + /// fault reported as data loss sends an operator looking for a backup instead + /// of a broken credential. + /// + /// Field 3: `unreadable` + #[must_use] + pub fn unreadable(&self) -> u32 { + self.0.reborrow().unreadable + } + /// Field 4: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ObservedIntegrityViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ObservedIntegrityViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ObservedIntegrityViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ObservedIntegrityViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ObservedIntegrityView { + type View<'a> = ObservedIntegrityViewView<'a>; + type ViewHandle = ObservedIntegrityViewOwnedView; +} +impl ::serde::Serialize for ObservedIntegrityViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ForkOriginView names the session this one branched from. +#[derive(Clone, Debug, Default)] +pub struct ForkOriginViewView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// The source ordinal this session's inherited context ends at. + /// + /// Field 2: `context_prefix_boundary` + pub context_prefix_boundary: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ForkOriginViewView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `context_prefix_boundary` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_context_prefix_boundary(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ForkOriginViewView<'a> { + type Owned = super::super::ForkOriginView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.context_prefix_boundary = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ForkOriginView { + source_session_id: self.source_session_id.to_string(), + context_prefix_boundary: self.context_prefix_boundary, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ForkOriginViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.context_prefix_boundary) + as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.context_prefix_boundary, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ForkOriginViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + __map + .serialize_entry( + "contextPrefixBoundary", + &::buffa::json_helpers::ProtoJson(&self.context_prefix_boundary), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ForkOriginViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ForkOriginView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ForkOriginView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ForkOriginView"; +} +::buffa::impl_default_view_instance!(ForkOriginViewView); +::buffa::impl_view_reborrow!(ForkOriginViewView); +/** Self-contained, `'static` owned view of a `ForkOriginView` message. + + Wraps [`::buffa::OwnedView`]`<`[`ForkOriginViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ForkOriginViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ForkOriginViewOwnedView(::buffa::OwnedView>); +impl ForkOriginViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginViewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ForkOriginView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ForkOriginViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ForkOriginViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ForkOriginView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// The source ordinal this session's inherited context ends at. + /// + /// Field 2: `context_prefix_boundary` + #[must_use] + pub fn context_prefix_boundary(&self) -> u64 { + self.0.reborrow().context_prefix_boundary + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ForkOriginViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ForkOriginViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ForkOriginViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ForkOriginViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ForkOriginView { + type View<'a> = ForkOriginViewView<'a>; + type ViewHandle = ForkOriginViewOwnedView; +} +impl ::serde::Serialize for ForkOriginViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ParentView names the session that dispatched this one, and whether that +/// lineage still holds. +#[derive(Clone, Debug, Default)] +pub struct ParentViewView<'a> { + /// Field 1: `parent_session_id` + pub parent_session_id: &'a str, + /// The parent ended and this session observed it. + /// + /// Field 2: `parent_terminated` + pub parent_terminated: bool, + /// The parent rewound past the dispatch: the inherited context no longer + /// exists, so this session's history is no longer grounded in the parent's. + /// + /// Field 3: `history_invalidated` + pub history_invalidated: bool, + /// The lineage was explicitly released. + /// + /// Field 4: `detached` + pub detached: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ParentViewView<'a> { + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `parent_terminated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_terminated(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `history_invalidated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_history_invalidated(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `detached` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_detached(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ParentViewView<'a> { + type Owned = super::super::ParentView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.parent_terminated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.history_invalidated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.detached = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ParentView { + parent_session_id: self.parent_session_id.to_string(), + parent_terminated: self.parent_terminated, + history_invalidated: self.history_invalidated, + detached: self.detached, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ParentViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.parent_session_id, buf); + ::buffa::types::put_bool_field(2u32, self.parent_terminated, buf); + ::buffa::types::put_bool_field(3u32, self.history_invalidated, buf); + ::buffa::types::put_bool_field(4u32, self.detached, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ParentViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + __map.serialize_entry("parentTerminated", &self.parent_terminated)?; + } + { + __map.serialize_entry("historyInvalidated", &self.history_invalidated)?; + } + { + __map.serialize_entry("detached", &self.detached)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ParentViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ParentView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ParentView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ParentView"; +} +::buffa::impl_default_view_instance!(ParentViewView); +::buffa::impl_view_reborrow!(ParentViewView); +/** Self-contained, `'static` owned view of a `ParentView` message. + + Wraps [`::buffa::OwnedView`]`<`[`ParentViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ParentViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ParentViewOwnedView(::buffa::OwnedView>); +impl ParentViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentViewOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ParentView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ParentViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ParentViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ParentView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// The parent ended and this session observed it. + /// + /// Field 2: `parent_terminated` + #[must_use] + pub fn parent_terminated(&self) -> bool { + self.0.reborrow().parent_terminated + } + /// The parent rewound past the dispatch: the inherited context no longer + /// exists, so this session's history is no longer grounded in the parent's. + /// + /// Field 3: `history_invalidated` + #[must_use] + pub fn history_invalidated(&self) -> bool { + self.0.reborrow().history_invalidated + } + /// The lineage was explicitly released. + /// + /// Field 4: `detached` + #[must_use] + pub fn detached(&self) -> bool { + self.0.reborrow().detached + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ParentViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ParentViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ParentViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ParentViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ParentView { + type View<'a> = ParentViewView<'a>; + type ViewHandle = ParentViewOwnedView; +} +impl ::serde::Serialize for ParentViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// DelegationView is one dispatched child or external delegate. +#[derive(Clone, Debug, Default)] +pub struct DelegationViewView<'a> { + /// Field 1: `operation_id` + pub operation_id: &'a str, + /// Field 2: `kind` + pub kind: ::buffa::EnumValue, + /// Set for DELEGATION_KIND_VIEW_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + pub child_session_id: ::core::option::Option<&'a str>, + /// Set for DELEGATION_KIND_VIEW_EXTERNAL. + /// + /// Field 4: `delegate_reference` + pub delegate_reference: ::core::option::Option<&'a str>, + /// Field 5: `detached` + pub detached: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DelegationViewView<'a> { + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `detached` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_detached(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DelegationViewView<'a> { + type Owned = super::super::DelegationView; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.child_session_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.delegate_reference = Some(::buffa::types::borrow_str(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.detached = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DelegationView { + operation_id: self.operation_id.to_string(), + kind: self.kind, + child_session_id: self.child_session_id.map(|s| s.to_string()), + delegate_reference: self.delegate_reference.map(|s| s.to_string()), + detached: self.detached, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DelegationViewView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.child_session_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.delegate_reference { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.child_session_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.delegate_reference { + ::buffa::types::put_string_field(4u32, v, buf); + } + ::buffa::types::put_bool_field(5u32, self.detached, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DelegationViewView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(__v) = self.child_session_id { + __map.serialize_entry("childSessionId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.delegate_reference { + __map.serialize_entry("delegateReference", __v)?; + } + { + __map.serialize_entry("detached", &self.detached)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DelegationViewView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "DelegationView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.DelegationView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.DelegationView"; +} +::buffa::impl_default_view_instance!(DelegationViewView); +::buffa::impl_view_reborrow!(DelegationViewView); +/** Self-contained, `'static` owned view of a `DelegationView` message. + + Wraps [`::buffa::OwnedView`]`<`[`DelegationViewView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DelegationViewView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DelegationViewOwnedView(::buffa::OwnedView>); +impl DelegationViewOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationViewOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationViewOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DelegationView, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationViewOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DelegationViewView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DelegationViewView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DelegationView { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 2: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Set for DELEGATION_KIND_VIEW_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + #[must_use] + pub fn child_session_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().child_session_id + } + /// Set for DELEGATION_KIND_VIEW_EXTERNAL. + /// + /// Field 4: `delegate_reference` + #[must_use] + pub fn delegate_reference(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().delegate_reference + } + /// Field 5: `detached` + #[must_use] + pub fn detached(&self) -> bool { + self.0.reborrow().detached + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DelegationViewOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DelegationViewOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DelegationViewOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DelegationViewOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DelegationView { + type View<'a> = DelegationViewView<'a>; + type ViewHandle = DelegationViewOwnedView; +} +impl ::serde::Serialize for DelegationViewOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.rs new file mode 100644 index 0000000000..c5774ce620 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.queries.v1alpha1.session_view.rs @@ -0,0 +1,2986 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/queries/v1alpha1/session_view.proto + +/// Read-model value types for the Session query contract. +/// +/// These are redefined here rather than imported from the write side on purpose +/// (ADR#0035 facet 3). The write-side event and state types change whenever the +/// domain changes; a public read contract must be able to hold still across +/// those changes, and a shared type would forward every write-side edit straight +/// to every client. +/// +/// Every identifier here is opaque. A caller may compare ids for equality and +/// pass them back, and must not parse structure out of them. +/// +/// SessionLifecycle is the coarse lifecycle state a reader sees. +/// +/// It is deliberately coarser than the write side's terminal markers: a reader +/// needs to know whether a session is still going, not which command sealed it. +/// The specific marker is available on `terminal_reason`. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SessionLifecycle { + SESSION_LIFECYCLE_UNSPECIFIED = 0i32, + SESSION_LIFECYCLE_ACTIVE = 1i32, + SESSION_LIFECYCLE_TERMINAL = 2i32, +} +impl SessionLifecycle { + ///Idiomatic alias for [`Self::SESSION_LIFECYCLE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SESSION_LIFECYCLE_UNSPECIFIED; + ///Idiomatic alias for [`Self::SESSION_LIFECYCLE_ACTIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Active: Self = Self::SESSION_LIFECYCLE_ACTIVE; + ///Idiomatic alias for [`Self::SESSION_LIFECYCLE_TERMINAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Terminal: Self = Self::SESSION_LIFECYCLE_TERMINAL; +} +impl ::core::default::Default for SessionLifecycle { + fn default() -> Self { + Self::SESSION_LIFECYCLE_UNSPECIFIED + } +} +impl ::serde::Serialize for SessionLifecycle { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SessionLifecycle { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SessionLifecycle; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(SessionLifecycle) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionLifecycle { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SessionLifecycle { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SESSION_LIFECYCLE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SESSION_LIFECYCLE_ACTIVE), + 2i32 => ::core::option::Option::Some(Self::SESSION_LIFECYCLE_TERMINAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SESSION_LIFECYCLE_UNSPECIFIED => "SESSION_LIFECYCLE_UNSPECIFIED", + Self::SESSION_LIFECYCLE_ACTIVE => "SESSION_LIFECYCLE_ACTIVE", + Self::SESSION_LIFECYCLE_TERMINAL => "SESSION_LIFECYCLE_TERMINAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SESSION_LIFECYCLE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SESSION_LIFECYCLE_UNSPECIFIED) + } + "SESSION_LIFECYCLE_ACTIVE" => { + ::core::option::Option::Some(Self::SESSION_LIFECYCLE_ACTIVE) + } + "SESSION_LIFECYCLE_TERMINAL" => { + ::core::option::Option::Some(Self::SESSION_LIFECYCLE_TERMINAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SESSION_LIFECYCLE_UNSPECIFIED, + Self::SESSION_LIFECYCLE_ACTIVE, + Self::SESSION_LIFECYCLE_TERMINAL, + ] + } +} +/// TerminalReason is why a session ended, set only for a terminal session. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TerminalReason { + TERMINAL_REASON_UNSPECIFIED = 0i32, + TERMINAL_REASON_CLOSED = 1i32, + TERMINAL_REASON_CANCELLED = 2i32, + TERMINAL_REASON_FAILED = 3i32, + TERMINAL_REASON_HIDDEN = 4i32, +} +impl TerminalReason { + ///Idiomatic alias for [`Self::TERMINAL_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TERMINAL_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::TERMINAL_REASON_CLOSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Closed: Self = Self::TERMINAL_REASON_CLOSED; + ///Idiomatic alias for [`Self::TERMINAL_REASON_CANCELLED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Cancelled: Self = Self::TERMINAL_REASON_CANCELLED; + ///Idiomatic alias for [`Self::TERMINAL_REASON_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::TERMINAL_REASON_FAILED; + ///Idiomatic alias for [`Self::TERMINAL_REASON_HIDDEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Hidden: Self = Self::TERMINAL_REASON_HIDDEN; +} +impl ::core::default::Default for TerminalReason { + fn default() -> Self { + Self::TERMINAL_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for TerminalReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TerminalReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TerminalReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TerminalReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TerminalReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TerminalReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TERMINAL_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TERMINAL_REASON_CLOSED), + 2i32 => ::core::option::Option::Some(Self::TERMINAL_REASON_CANCELLED), + 3i32 => ::core::option::Option::Some(Self::TERMINAL_REASON_FAILED), + 4i32 => ::core::option::Option::Some(Self::TERMINAL_REASON_HIDDEN), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TERMINAL_REASON_UNSPECIFIED => "TERMINAL_REASON_UNSPECIFIED", + Self::TERMINAL_REASON_CLOSED => "TERMINAL_REASON_CLOSED", + Self::TERMINAL_REASON_CANCELLED => "TERMINAL_REASON_CANCELLED", + Self::TERMINAL_REASON_FAILED => "TERMINAL_REASON_FAILED", + Self::TERMINAL_REASON_HIDDEN => "TERMINAL_REASON_HIDDEN", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TERMINAL_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TERMINAL_REASON_UNSPECIFIED) + } + "TERMINAL_REASON_CLOSED" => { + ::core::option::Option::Some(Self::TERMINAL_REASON_CLOSED) + } + "TERMINAL_REASON_CANCELLED" => { + ::core::option::Option::Some(Self::TERMINAL_REASON_CANCELLED) + } + "TERMINAL_REASON_FAILED" => { + ::core::option::Option::Some(Self::TERMINAL_REASON_FAILED) + } + "TERMINAL_REASON_HIDDEN" => { + ::core::option::Option::Some(Self::TERMINAL_REASON_HIDDEN) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TERMINAL_REASON_UNSPECIFIED, + Self::TERMINAL_REASON_CLOSED, + Self::TERMINAL_REASON_CANCELLED, + Self::TERMINAL_REASON_FAILED, + Self::TERMINAL_REASON_HIDDEN, + ] + } +} +/// SessionPreviewAvailability is why a preview is or is not there. +/// +/// Absence has several causes with different meanings, and collapsing them into +/// an empty string tells a user that a session is empty when it may only be one +/// they are not cleared to see, or one whose opening message was deliberately +/// removed. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SessionPreviewAvailability { + SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED = 0i32, + /// An excerpt is present in `text`. + SESSION_PREVIEW_AVAILABILITY_AVAILABLE = 1i32, + /// The session has no effective authored content to preview. + SESSION_PREVIEW_AVAILABILITY_EMPTY = 2i32, + /// Content exists but is not text: an image-only or attachment-only opening. + SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL = 3i32, + /// The content a preview would come from was redacted. Distinguished from empty + /// because a session that was emptied on purpose is not a session that was + /// never used, and a UI that says "no messages" about a redaction is lying + /// about what happened. + SESSION_PREVIEW_AVAILABILITY_REDACTED = 4i32, + /// The content exists and this caller may not see it. Per-caller, like + /// ArtifactCompletenessView.hidden: two readers of the same session can get + /// different answers, and the difference is authorization rather than content. + SESSION_PREVIEW_AVAILABILITY_WITHHELD = 5i32, +} +impl SessionPreviewAvailability { + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Available: Self = Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE; + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_EMPTY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Empty: Self = Self::SESSION_PREVIEW_AVAILABILITY_EMPTY; + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NonTextual: Self = Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL; + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_REDACTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Redacted: Self = Self::SESSION_PREVIEW_AVAILABILITY_REDACTED; + ///Idiomatic alias for [`Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Withheld: Self = Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD; +} +impl ::core::default::Default for SessionPreviewAvailability { + fn default() -> Self { + Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED + } +} +impl ::serde::Serialize for SessionPreviewAvailability { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SessionPreviewAvailability { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SessionPreviewAvailability; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(SessionPreviewAvailability) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionPreviewAvailability { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SessionPreviewAvailability { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED, + ) + } + 1i32 => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE, + ) + } + 2i32 => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_EMPTY) + } + 3i32 => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL, + ) + } + 4i32 => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_REDACTED) + } + 5i32 => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED => { + "SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED" + } + Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE => { + "SESSION_PREVIEW_AVAILABILITY_AVAILABLE" + } + Self::SESSION_PREVIEW_AVAILABILITY_EMPTY => { + "SESSION_PREVIEW_AVAILABILITY_EMPTY" + } + Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL => { + "SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL" + } + Self::SESSION_PREVIEW_AVAILABILITY_REDACTED => { + "SESSION_PREVIEW_AVAILABILITY_REDACTED" + } + Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD => { + "SESSION_PREVIEW_AVAILABILITY_WITHHELD" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED" => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED, + ) + } + "SESSION_PREVIEW_AVAILABILITY_AVAILABLE" => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE, + ) + } + "SESSION_PREVIEW_AVAILABILITY_EMPTY" => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_EMPTY) + } + "SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL" => { + ::core::option::Option::Some( + Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL, + ) + } + "SESSION_PREVIEW_AVAILABILITY_REDACTED" => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_REDACTED) + } + "SESSION_PREVIEW_AVAILABILITY_WITHHELD" => { + ::core::option::Option::Some(Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SESSION_PREVIEW_AVAILABILITY_UNSPECIFIED, + Self::SESSION_PREVIEW_AVAILABILITY_AVAILABLE, + Self::SESSION_PREVIEW_AVAILABILITY_EMPTY, + Self::SESSION_PREVIEW_AVAILABILITY_NON_TEXTUAL, + Self::SESSION_PREVIEW_AVAILABILITY_REDACTED, + Self::SESSION_PREVIEW_AVAILABILITY_WITHHELD, + ] + } +} +/// RecoveryCompletenessView is how much of the source a salvaged session carries. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RecoveryCompletenessView { + RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED = 0i32, + RECOVERY_COMPLETENESS_VIEW_COMPLETE = 1i32, + RECOVERY_COMPLETENESS_VIEW_PARTIAL = 2i32, +} +impl RecoveryCompletenessView { + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED; + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Complete: Self = Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE; + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Partial: Self = Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL; +} +impl ::core::default::Default for RecoveryCompletenessView { + fn default() -> Self { + Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED + } +} +impl ::serde::Serialize for RecoveryCompletenessView { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RecoveryCompletenessView { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RecoveryCompletenessView; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(RecoveryCompletenessView) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecoveryCompletenessView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RecoveryCompletenessView { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some( + Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED, + ) + } + 1i32 => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE) + } + 2i32 => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED => { + "RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED" + } + Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE => { + "RECOVERY_COMPLETENESS_VIEW_COMPLETE" + } + Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL => { + "RECOVERY_COMPLETENESS_VIEW_PARTIAL" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED" => { + ::core::option::Option::Some( + Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED, + ) + } + "RECOVERY_COMPLETENESS_VIEW_COMPLETE" => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE) + } + "RECOVERY_COMPLETENESS_VIEW_PARTIAL" => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RECOVERY_COMPLETENESS_VIEW_UNSPECIFIED, + Self::RECOVERY_COMPLETENESS_VIEW_COMPLETE, + Self::RECOVERY_COMPLETENESS_VIEW_PARTIAL, + ] + } +} +/// TitleSource says where a rendered title came from, and by doing so fixes the +/// precedence that produced it. +/// +/// The projection resolves a title in one order, always: the latest effective +/// SessionRenamed if one survives, otherwise a title derived from the first +/// effective user message, otherwise a fallback. Publishing which rule fired is +/// what makes the result checkable, and it lets a client style a guess +/// differently from a name a human chose. +/// +/// The two sources invalidate differently, and that asymmetry is the reason this +/// field exists rather than a `title_is_explicit` bool. A derived title is a +/// function of effective history, so a rewind past the first user message or a +/// redaction of it changes the title. An explicit title is an authoritative fact +/// of its own and survives both. What it does not survive is being redacted +/// itself, and when that happens the resolution falls back down the same +/// precedence rather than keeping a name whose source no longer exists. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TitleSource { + TITLE_SOURCE_UNSPECIFIED = 0i32, + /// A human renamed the session, and that rename is still effective. + TITLE_SOURCE_EXPLICIT = 1i32, + /// Derived from the first effective user message. Follows effective history: + /// rewinding or redacting that message changes it. + TITLE_SOURCE_DERIVED = 2i32, + /// Nothing to derive from: an empty or image-only session, or one whose + /// openings are all masked. The server supplies the string. + TITLE_SOURCE_FALLBACK = 3i32, +} +impl TitleSource { + ///Idiomatic alias for [`Self::TITLE_SOURCE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TITLE_SOURCE_UNSPECIFIED; + ///Idiomatic alias for [`Self::TITLE_SOURCE_EXPLICIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Explicit: Self = Self::TITLE_SOURCE_EXPLICIT; + ///Idiomatic alias for [`Self::TITLE_SOURCE_DERIVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Derived: Self = Self::TITLE_SOURCE_DERIVED; + ///Idiomatic alias for [`Self::TITLE_SOURCE_FALLBACK`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Fallback: Self = Self::TITLE_SOURCE_FALLBACK; +} +impl ::core::default::Default for TitleSource { + fn default() -> Self { + Self::TITLE_SOURCE_UNSPECIFIED + } +} +impl ::serde::Serialize for TitleSource { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TitleSource { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TitleSource; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(TitleSource)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TitleSource { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TitleSource { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TITLE_SOURCE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TITLE_SOURCE_EXPLICIT), + 2i32 => ::core::option::Option::Some(Self::TITLE_SOURCE_DERIVED), + 3i32 => ::core::option::Option::Some(Self::TITLE_SOURCE_FALLBACK), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TITLE_SOURCE_UNSPECIFIED => "TITLE_SOURCE_UNSPECIFIED", + Self::TITLE_SOURCE_EXPLICIT => "TITLE_SOURCE_EXPLICIT", + Self::TITLE_SOURCE_DERIVED => "TITLE_SOURCE_DERIVED", + Self::TITLE_SOURCE_FALLBACK => "TITLE_SOURCE_FALLBACK", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TITLE_SOURCE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TITLE_SOURCE_UNSPECIFIED) + } + "TITLE_SOURCE_EXPLICIT" => { + ::core::option::Option::Some(Self::TITLE_SOURCE_EXPLICIT) + } + "TITLE_SOURCE_DERIVED" => { + ::core::option::Option::Some(Self::TITLE_SOURCE_DERIVED) + } + "TITLE_SOURCE_FALLBACK" => { + ::core::option::Option::Some(Self::TITLE_SOURCE_FALLBACK) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TITLE_SOURCE_UNSPECIFIED, + Self::TITLE_SOURCE_EXPLICIT, + Self::TITLE_SOURCE_DERIVED, + Self::TITLE_SOURCE_FALLBACK, + ] + } +} +/// DelegationKindView is where delegated work runs. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum DelegationKindView { + DELEGATION_KIND_VIEW_UNSPECIFIED = 0i32, + DELEGATION_KIND_VIEW_CHILD_SESSION = 1i32, + DELEGATION_KIND_VIEW_EXTERNAL = 2i32, +} +impl DelegationKindView { + ///Idiomatic alias for [`Self::DELEGATION_KIND_VIEW_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::DELEGATION_KIND_VIEW_UNSPECIFIED; + ///Idiomatic alias for [`Self::DELEGATION_KIND_VIEW_CHILD_SESSION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChildSession: Self = Self::DELEGATION_KIND_VIEW_CHILD_SESSION; + ///Idiomatic alias for [`Self::DELEGATION_KIND_VIEW_EXTERNAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const External: Self = Self::DELEGATION_KIND_VIEW_EXTERNAL; +} +impl ::core::default::Default for DelegationKindView { + fn default() -> Self { + Self::DELEGATION_KIND_VIEW_UNSPECIFIED + } +} +impl ::serde::Serialize for DelegationKindView { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for DelegationKindView { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = DelegationKindView; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(DelegationKindView) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for DelegationKindView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for DelegationKindView { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_CHILD_SESSION) + } + 2i32 => ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_EXTERNAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::DELEGATION_KIND_VIEW_UNSPECIFIED => "DELEGATION_KIND_VIEW_UNSPECIFIED", + Self::DELEGATION_KIND_VIEW_CHILD_SESSION => { + "DELEGATION_KIND_VIEW_CHILD_SESSION" + } + Self::DELEGATION_KIND_VIEW_EXTERNAL => "DELEGATION_KIND_VIEW_EXTERNAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "DELEGATION_KIND_VIEW_UNSPECIFIED" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_UNSPECIFIED) + } + "DELEGATION_KIND_VIEW_CHILD_SESSION" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_CHILD_SESSION) + } + "DELEGATION_KIND_VIEW_EXTERNAL" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_VIEW_EXTERNAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::DELEGATION_KIND_VIEW_UNSPECIFIED, + Self::DELEGATION_KIND_VIEW_CHILD_SESSION, + Self::DELEGATION_KIND_VIEW_EXTERNAL, + ] + } +} +/// SessionSummary is the list-row shape: enough to render a picker, and no more. +/// +/// It deliberately excludes anything requiring a per-session fan-out to compute, +/// because a list query that costs one read per row stops being a list query. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionSummary { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `lifecycle` + #[serde(rename = "lifecycle", with = "::buffa::json_helpers::proto_enum")] + pub lifecycle: ::buffa::EnumValue, + /// Unset while the session is active. + /// + /// Field 3: `terminal_reason` + #[serde( + rename = "terminalReason", + alias = "terminal_reason", + with = "::buffa::json_helpers::opt_enum", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub terminal_reason: ::core::option::Option<::buffa::EnumValue>, + /// Display name, resolved by the precedence on TitleSource. Always set: when + /// there is nothing to show it holds a server-chosen fallback rather than an + /// empty string, so a picker never has to invent one and two clients never + /// invent different ones. + /// + /// Field 4: `title` + #[serde(rename = "title", with = "::buffa::json_helpers::proto_string")] + pub title: ::buffa::alloc::string::String, + /// Field 5: `title_source` + #[serde( + rename = "titleSource", + alias = "title_source", + with = "::buffa::json_helpers::proto_enum" + )] + pub title_source: ::buffa::EnumValue, + /// Field 6: `workspace_id` + #[serde( + rename = "workspaceId", + alias = "workspace_id", + with = "::buffa::json_helpers::proto_string" + )] + pub workspace_id: ::buffa::alloc::string::String, + /// Field 7: `archived` + #[serde(rename = "archived", with = "::buffa::json_helpers::proto_bool")] + pub archived: bool, + /// Effective history length in SessionOrdinals, after rewind masking. A caller + /// must not treat this as a count of decodable history items: redaction can + /// mask an ordinal without removing it. + /// + /// Field 8: `effective_length` + #[serde( + rename = "effectiveLength", + alias = "effective_length", + with = "::buffa::json_helpers::uint64" + )] + pub effective_length: u64, + /// Set when this session is a copy salvaged from a damaged one. On the list row + /// and not only the detail view, because a picker that renders a salvaged + /// session identically to an intact one is where the substitution actually + /// happens: by the time a user opens it they have already decided it is theirs. + /// + /// Field 9: `recovery` + #[serde( + rename = "recovery", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub recovery: ::buffa::MessageField< + RecoveryProvenanceView, + ::buffa::Inline, + >, + /// Short excerpt of the session's opening content. Always set, including when + /// there is nothing to preview, because the reason there is nothing is itself + /// what a caller needs in order to render the row honestly. + /// + /// Field 10: `preview` + #[serde(rename = "preview")] + pub preview: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for SessionSummary { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionSummary") + .field("session_id", &self.session_id) + .field("lifecycle", &self.lifecycle) + .field("terminal_reason", &self.terminal_reason) + .field("title", &self.title) + .field("title_source", &self.title_source) + .field("workspace_id", &self.workspace_id) + .field("archived", &self.archived) + .field("effective_length", &self.effective_length) + .field("recovery", &self.recovery) + .field("preview", &self.preview) + .finish() + } +} +impl SessionSummary { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionSummary"; +} +impl SessionSummary { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::terminal_reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_terminal_reason( + mut self, + value: impl Into<::buffa::EnumValue>, + ) -> Self { + self.terminal_reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(SessionSummary); +impl ::buffa::MessageName for SessionSummary { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionSummary"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionSummary"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionSummary"; +} +impl ::buffa::Message for SessionSummary { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.lifecycle.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.terminal_reason { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.title) as u64; + { + let val = self.title_source.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.workspace_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.effective_length) as u64; + if self.recovery.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.recovery.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.preview.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.preview.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.lifecycle.to_i32(), buf); + if let Some(ref v) = self.terminal_reason { + ::buffa::types::put_int32_field(3u32, v.to_i32(), buf); + } + ::buffa::types::put_string_field(4u32, &self.title, buf); + ::buffa::types::put_int32_field(5u32, self.title_source.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.workspace_id, buf); + ::buffa::types::put_bool_field(7u32, self.archived, buf); + ::buffa::types::put_uint64_field(8u32, self.effective_length, buf); + if self.recovery.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.recovery.write_to(__cache, buf); + } + if self.preview.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.preview.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.lifecycle = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.terminal_reason = ::core::option::Option::Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.title, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.title_source = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.workspace_id, buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.archived = ::buffa::types::decode_bool(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.effective_length = ::buffa::types::decode_uint64(buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.recovery.get_or_insert_default(), + buf, + ctx, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.preview.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.lifecycle = ::buffa::EnumValue::from(0); + self.terminal_reason = ::core::option::Option::None; + self.title.clear(); + self.title_source = ::buffa::EnumValue::from(0); + self.workspace_id.clear(); + self.archived = false; + self.effective_length = 0u64; + self.recovery = ::buffa::MessageField::none(); + self.preview = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionSummary { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_SUMMARY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionSummary", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SessionPreview is the excerpt shown beneath a session's title. +/// +/// It is derived from effective history, which is what makes it a projection +/// concern rather than a stored string. Rewind masks ordinals, redaction removes +/// content from ordinals that remain, and either can take away the very message a +/// preview was cut from. A preview cached without regard for that is the case +/// where deliberately destroyed text reappears on a screen, which is a privacy +/// failure and not a staleness annoyance. +/// +/// Its validity therefore tracks `effective_history_revision` and +/// `privacy_revision`, the same two coordinates a presentation cache binds +/// against. A cached preview whose binding fails those two must be discarded, not +/// shown as merely older. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionPreview { + /// The excerpt, truncated at a server-chosen bound. Empty for every + /// availability other than SESSION_PREVIEW_AVAILABILITY_AVAILABLE. + /// + /// Field 1: `text` + #[serde(rename = "text", with = "::buffa::json_helpers::proto_string")] + pub text: ::buffa::alloc::string::String, + /// Field 2: `availability` + #[serde(rename = "availability", with = "::buffa::json_helpers::proto_enum")] + pub availability: ::buffa::EnumValue, + /// True when the excerpt is shorter than the content it came from, so a + /// renderer can mark the cut rather than presenting a fragment as a whole + /// message. + /// + /// Field 3: `truncated` + #[serde(rename = "truncated", with = "::buffa::json_helpers::proto_bool")] + pub truncated: bool, +} +impl ::core::fmt::Debug for SessionPreview { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionPreview") + .field("text", &self.text) + .field("availability", &self.availability) + .field("truncated", &self.truncated) + .finish() + } +} +impl SessionPreview { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionPreview"; +} +::buffa::impl_default_instance!(SessionPreview); +impl ::buffa::MessageName for SessionPreview { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionPreview"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionPreview"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionPreview"; +} +impl ::buffa::Message for SessionPreview { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + { + let val = self.availability.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.text, buf); + ::buffa::types::put_int32_field(2u32, self.availability.to_i32(), buf); + ::buffa::types::put_bool_field(3u32, self.truncated, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.text, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.availability = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.truncated = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.text.clear(); + self.availability = ::buffa::EnumValue::from(0); + self.truncated = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionPreview { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_PREVIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionPreview", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RecoveryProvenanceView marks a session that was salvaged rather than lived. +/// +/// Unset is the ordinary case. When set, a reader must not present the session as +/// the source: it has a different id, its ordinals are its own, and a partial +/// recovery is missing content the original had. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecoveryProvenanceView { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// Field 2: `completeness` + #[serde(rename = "completeness", with = "::buffa::json_helpers::proto_enum")] + pub completeness: ::buffa::EnumValue, + /// How many source items the salvage could not carry. The enumeration is an + /// operator-side record and is deliberately not on the read contract: a client + /// needs to know the session is incomplete, not to render a damage report. + /// + /// Field 3: `omitted_count` + #[serde( + rename = "omittedCount", + alias = "omitted_count", + with = "::buffa::json_helpers::uint32" + )] + pub omitted_count: u32, +} +impl ::core::fmt::Debug for RecoveryProvenanceView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecoveryProvenanceView") + .field("source_session_id", &self.source_session_id) + .field("completeness", &self.completeness) + .field("omitted_count", &self.omitted_count) + .finish() + } +} +impl RecoveryProvenanceView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView"; +} +::buffa::impl_default_instance!(RecoveryProvenanceView); +impl ::buffa::MessageName for RecoveryProvenanceView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "RecoveryProvenanceView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView"; +} +impl ::buffa::Message for RecoveryProvenanceView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_int32_field(2u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(3u32, self.omitted_count, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.omitted_count = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.completeness = ::buffa::EnumValue::from(0); + self.omitted_count = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecoveryProvenanceView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECOVERY_PROVENANCE_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.RecoveryProvenanceView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SessionView is the detail shape returned by GetSession. +/// +/// It reports lifecycle and shape, never the transcript. History is a separate, +/// paginated query because a session's history has no bound and a detail read +/// that inlines it has no bound either. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionView { + /// Field 1: `summary` + #[serde(rename = "summary")] + pub summary: ::buffa::MessageField>, + /// Set when this session was forked from another. + /// + /// Field 2: `fork_origin` + #[serde( + rename = "forkOrigin", + alias = "fork_origin", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub fork_origin: ::buffa::MessageField< + ForkOriginView, + ::buffa::Inline, + >, + /// Set when this session was dispatched by a parent. + /// + /// Field 3: `parent` + #[serde( + rename = "parent", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub parent: ::buffa::MessageField>, + /// Sessions this one dispatched, parent side. + /// + /// Field 4: `delegations` + #[serde( + rename = "delegations", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub delegations: ::buffa::alloc::vec::Vec, + /// True when at least one tool call has started with no terminal outcome, or + /// at least one reserved operation is unsettled. This is the reader-visible + /// form of "something needs reconciling"; a caller must not conclude a session + /// is complete from a terminal lifecycle alone. + /// + /// Field 5: `has_unreconciled_work` + #[serde( + rename = "hasUnreconciledWork", + alias = "has_unreconciled_work", + with = "::buffa::json_helpers::proto_bool" + )] + pub has_unreconciled_work: bool, + /// How much of this session's artifact content is still retrievable. Always + /// set, including when everything is intact, so a caller never has to read an + /// absent field as good news. + /// + /// Field 6: `artifacts` + #[serde(rename = "artifacts")] + pub artifacts: ::buffa::MessageField< + ArtifactCompletenessView, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for SessionView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionView") + .field("summary", &self.summary) + .field("fork_origin", &self.fork_origin) + .field("parent", &self.parent) + .field("delegations", &self.delegations) + .field("has_unreconciled_work", &self.has_unreconciled_work) + .field("artifacts", &self.artifacts) + .finish() + } +} +impl SessionView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionView"; +} +::buffa::impl_default_instance!(SessionView); +impl ::buffa::MessageName for SessionView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "SessionView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.SessionView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionView"; +} +impl ::buffa::Message for SessionView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.summary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.summary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.fork_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fork_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.parent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.delegations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.artifacts.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifacts.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.summary.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.summary.write_to(__cache, buf); + } + if self.fork_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.fork_origin.write_to(__cache, buf); + } + if self.parent.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent.write_to(__cache, buf); + } + for v in &self.delegations { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(5u32, self.has_unreconciled_work, buf); + if self.artifacts.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifacts.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.summary.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.fork_origin.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.parent.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.delegations.push(elem); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.has_unreconciled_work = ::buffa::types::decode_bool(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.artifacts.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.summary = ::buffa::MessageField::none(); + self.fork_origin = ::buffa::MessageField::none(); + self.parent = ::buffa::MessageField::none(); + self.delegations.clear(); + self.has_unreconciled_work = false; + self.artifacts = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.SessionView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ArtifactCompletenessView is how complete this session's artifact content is, +/// reported separately from its lifecycle. +/// +/// The two are independent and routinely disagree. A session can close having +/// done exactly what was asked and still be missing the output it produced, +/// because artifact bytes live outside the log and outlive nothing in +/// particular: they get erased under a retention policy, or under a deletion +/// request, or by a storage fault. A reader that infers retrievability from +/// TERMINAL_REASON_CLOSED will present an empty result as a successful one. +/// +/// This rollup counts only what the log itself establishes. Whether the bytes an +/// intact claim-check points to are actually there is a fact about an external +/// store, and learning it costs one probe per artifact, which is not something a +/// list or detail query can do and remain a query. That answer arrives through +/// `observed` when someone has gone and looked. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ArtifactCompletenessView { + /// Artifacts recorded on this session's effective history. Rewind-masked and + /// redacted ordinals contribute nothing, so this counts what the caller can + /// see referenced rather than everything ever recorded. + /// + /// Field 1: `recorded` + #[serde(rename = "recorded", with = "::buffa::json_helpers::uint32")] + pub recorded: u32, + /// Recorded with durably stored bytes and no erasure since. This is the count + /// the log supports; it is a claim about what was promised, not about what a + /// store would return right now. + /// + /// Field 2: `claimed_retrievable` + #[serde( + rename = "claimedRetrievable", + alias = "claimed_retrievable", + with = "::buffa::json_helpers::uint32" + )] + pub claimed_retrievable: u32, + /// Destroyed on purpose, recorded by ArtifactErased. Counted apart from every + /// other absence because it is the one that is working as intended. + /// + /// Field 3: `erased` + #[serde(rename = "erased", with = "::buffa::json_helpers::uint32")] + pub erased: u32, + /// Recorded as an external reference whose bytes were never durably stored. + /// Nothing was lost; nothing was ever held. + /// + /// Field 4: `external_only` + #[serde( + rename = "externalOnly", + alias = "external_only", + with = "::buffa::json_helpers::uint32" + )] + pub external_only: u32, + /// Referenced by this session and not readable by this caller. Per-caller, so + /// two readers of the same session can see different totals, and the point of + /// surfacing it is that the difference is authorization rather than damage. + /// + /// Field 5: `hidden` + #[serde(rename = "hidden", with = "::buffa::json_helpers::uint32")] + pub hidden: u32, + /// Set only when the artifact store has actually been checked for this + /// session. Unset means nobody has looked, which is not the same as nothing + /// being wrong, and the field is absent rather than zeroed so the two cannot + /// be confused. + /// + /// Field 6: `observed` + #[serde( + rename = "observed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub observed: ::buffa::MessageField< + ObservedIntegrityView, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ArtifactCompletenessView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ArtifactCompletenessView") + .field("recorded", &self.recorded) + .field("claimed_retrievable", &self.claimed_retrievable) + .field("erased", &self.erased) + .field("external_only", &self.external_only) + .field("hidden", &self.hidden) + .field("observed", &self.observed) + .finish() + } +} +impl ArtifactCompletenessView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView"; +} +::buffa::impl_default_instance!(ArtifactCompletenessView); +impl ::buffa::MessageName for ArtifactCompletenessView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ArtifactCompletenessView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView"; +} +impl ::buffa::Message for ArtifactCompletenessView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.recorded) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.claimed_retrievable) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.erased) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.external_only) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.hidden) as u64; + if self.observed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.recorded, buf); + ::buffa::types::put_uint32_field(2u32, self.claimed_retrievable, buf); + ::buffa::types::put_uint32_field(3u32, self.erased, buf); + ::buffa::types::put_uint32_field(4u32, self.external_only, buf); + ::buffa::types::put_uint32_field(5u32, self.hidden, buf); + if self.observed.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.recorded = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.claimed_retrievable = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.erased = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.external_only = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.hidden = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.recorded = 0u32; + self.claimed_retrievable = 0u32; + self.erased = 0u32; + self.external_only = 0u32; + self.hidden = 0u32; + self.observed = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArtifactCompletenessView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ARTIFACT_COMPLETENESS_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ArtifactCompletenessView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ObservedIntegrityView is what a probe of the artifact store found, and when. +/// +/// These counts age. They describe a store at the instant it was read, and an +/// artifact can be lost the moment after; `observed_at` is here so a caller can +/// decide whether the answer is still worth acting on rather than treating a +/// stale all-clear as a current one. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ObservedIntegrityView { + /// Claim-checks the store had no object for, with no erasure recorded. This is + /// the count that means data was lost. + /// + /// Field 1: `missing` + #[serde(rename = "missing", with = "::buffa::json_helpers::uint32")] + pub missing: u32, + /// Objects present whose content does not match the digest on the log. + /// + /// Field 2: `digest_mismatch` + #[serde( + rename = "digestMismatch", + alias = "digest_mismatch", + with = "::buffa::json_helpers::uint32" + )] + pub digest_mismatch: u32, + /// Objects that could not be read at all, which makes no claim about whether + /// they exist. Counted apart from `missing` because a transport or permissions + /// fault reported as data loss sends an operator looking for a backup instead + /// of a broken credential. + /// + /// Field 3: `unreadable` + #[serde(rename = "unreadable", with = "::buffa::json_helpers::uint32")] + pub unreadable: u32, + /// Field 4: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ObservedIntegrityView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObservedIntegrityView") + .field("missing", &self.missing) + .field("digest_mismatch", &self.digest_mismatch) + .field("unreadable", &self.unreadable) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl ObservedIntegrityView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView"; +} +::buffa::impl_default_instance!(ObservedIntegrityView); +impl ::buffa::MessageName for ObservedIntegrityView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ObservedIntegrityView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView"; +} +impl ::buffa::Message for ObservedIntegrityView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.missing) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.digest_mismatch) as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unreadable) as u64; + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint32_field(1u32, self.missing, buf); + ::buffa::types::put_uint32_field(2u32, self.digest_mismatch, buf); + ::buffa::types::put_uint32_field(3u32, self.unreadable, buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.missing = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.digest_mismatch = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.unreadable = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.missing = 0u32; + self.digest_mismatch = 0u32; + self.unreadable = 0u32; + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ObservedIntegrityView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OBSERVED_INTEGRITY_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ObservedIntegrityView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ForkOriginView names the session this one branched from. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ForkOriginView { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// The source ordinal this session's inherited context ends at. + /// + /// Field 2: `context_prefix_boundary` + #[serde( + rename = "contextPrefixBoundary", + alias = "context_prefix_boundary", + with = "::buffa::json_helpers::uint64" + )] + pub context_prefix_boundary: u64, +} +impl ::core::fmt::Debug for ForkOriginView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ForkOriginView") + .field("source_session_id", &self.source_session_id) + .field("context_prefix_boundary", &self.context_prefix_boundary) + .finish() + } +} +impl ForkOriginView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ForkOriginView"; +} +::buffa::impl_default_instance!(ForkOriginView); +impl ::buffa::MessageName for ForkOriginView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ForkOriginView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ForkOriginView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ForkOriginView"; +} +impl ::buffa::Message for ForkOriginView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.context_prefix_boundary) + as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.context_prefix_boundary, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.context_prefix_boundary = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.context_prefix_boundary = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ForkOriginView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FORK_ORIGIN_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ForkOriginView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ParentView names the session that dispatched this one, and whether that +/// lineage still holds. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ParentView { + /// Field 1: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// The parent ended and this session observed it. + /// + /// Field 2: `parent_terminated` + #[serde( + rename = "parentTerminated", + alias = "parent_terminated", + with = "::buffa::json_helpers::proto_bool" + )] + pub parent_terminated: bool, + /// The parent rewound past the dispatch: the inherited context no longer + /// exists, so this session's history is no longer grounded in the parent's. + /// + /// Field 3: `history_invalidated` + #[serde( + rename = "historyInvalidated", + alias = "history_invalidated", + with = "::buffa::json_helpers::proto_bool" + )] + pub history_invalidated: bool, + /// The lineage was explicitly released. + /// + /// Field 4: `detached` + #[serde(rename = "detached", with = "::buffa::json_helpers::proto_bool")] + pub detached: bool, +} +impl ::core::fmt::Debug for ParentView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ParentView") + .field("parent_session_id", &self.parent_session_id) + .field("parent_terminated", &self.parent_terminated) + .field("history_invalidated", &self.history_invalidated) + .field("detached", &self.detached) + .finish() + } +} +impl ParentView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ParentView"; +} +::buffa::impl_default_instance!(ParentView); +impl ::buffa::MessageName for ParentView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "ParentView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.ParentView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ParentView"; +} +impl ::buffa::Message for ParentView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.parent_session_id, buf); + ::buffa::types::put_bool_field(2u32, self.parent_terminated, buf); + ::buffa::types::put_bool_field(3u32, self.history_invalidated, buf); + ::buffa::types::put_bool_field(4u32, self.detached, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.parent_terminated = ::buffa::types::decode_bool(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.history_invalidated = ::buffa::types::decode_bool(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.detached = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.parent_session_id.clear(); + self.parent_terminated = false; + self.history_invalidated = false; + self.detached = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ParentView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PARENT_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.ParentView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// DelegationView is one dispatched child or external delegate. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DelegationView { + /// Field 1: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 2: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Set for DELEGATION_KIND_VIEW_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + #[serde( + rename = "childSessionId", + alias = "child_session_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub child_session_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Set for DELEGATION_KIND_VIEW_EXTERNAL. + /// + /// Field 4: `delegate_reference` + #[serde( + rename = "delegateReference", + alias = "delegate_reference", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub delegate_reference: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 5: `detached` + #[serde(rename = "detached", with = "::buffa::json_helpers::proto_bool")] + pub detached: bool, +} +impl ::core::fmt::Debug for DelegationView { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DelegationView") + .field("operation_id", &self.operation_id) + .field("kind", &self.kind) + .field("child_session_id", &self.child_session_id) + .field("delegate_reference", &self.delegate_reference) + .field("detached", &self.detached) + .finish() + } +} +impl DelegationView { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.DelegationView"; +} +impl DelegationView { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::child_session_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_child_session_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.child_session_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::delegate_reference`] to `Some(value)`, consuming and returning `self`. + pub fn with_delegate_reference( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.delegate_reference = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DelegationView); +impl ::buffa::MessageName for DelegationView { + const PACKAGE: &'static str = "trogonai.session.sessions.queries.v1alpha1"; + const NAME: &'static str = "DelegationView"; + const FULL_NAME: &'static str = "trogonai.session.sessions.queries.v1alpha1.DelegationView"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.DelegationView"; +} +impl ::buffa::Message for DelegationView { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.child_session_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.delegate_reference { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.child_session_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.delegate_reference { + ::buffa::types::put_string_field(4u32, v, buf); + } + ::buffa::types::put_bool_field(5u32, self.detached, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .child_session_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .delegate_reference + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.detached = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.operation_id.clear(); + self.kind = ::buffa::EnumValue::from(0); + self.child_session_id = ::core::option::Option::None; + self.delegate_reference = ::core::option::Option::None; + self.detached = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DelegationView { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DELEGATION_VIEW_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.queries.v1alpha1.DelegationView", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.__view.rs new file mode 100644 index 0000000000..0f15562779 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.__view.rs @@ -0,0 +1,426 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/replay/v1alpha1/frame.proto + +/// The byte layout of a command-output replay artifact, format version 1. +/// +/// An artifact is two regions. The frame region runs from offset 0 and holds +/// frames back to back, each one a little-endian uint32 byte length followed by +/// that many bytes of a serialized ReplayFrame. The index region is a trailer +/// holding a serialized ReplayIndex; its offset and length are recorded on the +/// log, in CommandOutputReplayRef. +/// +/// These types are defined here rather than on the write side because they +/// describe bytes a reader parses, not a field an event carries. The write side +/// records where the capture is and what it is worth; this is what is inside it, +/// and the two change for different reasons (ADR#0035 facet 3). +/// +/// ReplayFrame is one contiguous run of output the capturer read in one go. +/// +/// A frame boundary is a fact about the capturer's read loop and nothing else. +/// It is not a line, not a write() by the process, and not a flush. A renderer +/// that treats frames as lines will split a line that arrived in two reads, and +/// it will do it differently on a fast machine than a slow one. +#[derive(Clone, Debug, Default)] +pub struct ReplayFrameView<'a> { + /// The capturer's own count, starting at 0, never compacted. + /// + /// When frames are dropped the surviving ones keep the numbers they were + /// given, so a gap in this sequence is a gap in the output. Renumbering to + /// stay contiguous would erase the only evidence inside the artifact that + /// anything is missing. + /// + /// Field 1: `sequence` + pub sequence: u64, + /// Field 2: `stream` + pub stream: ::buffa::EnumValue, + /// Raw bytes as captured. Not decoded, not normalized, and specifically not + /// stripped of control sequences: a terminal replay that removes them is + /// replaying something the terminal never showed. Decoding is the renderer's + /// job and is a decision it gets to make at render time, more than once. + /// + /// Field 3: `payload` + pub payload: ::core::option::Option<&'a [u8]>, + /// Elapsed time from the start of capture to when the capturer observed this + /// frame. Present only when CommandOutputReplayRef.timing is + /// TIMING_FIDELITY_CAPTURE_ELAPSED, and unset on every frame otherwise. + /// + /// Field 4: `elapsed` + pub elapsed: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReplayFrameView<'a> { + /**Whether required field `sequence` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_sequence(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `stream` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_stream(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReplayFrameView<'a> { + type Owned = super::super::ReplayFrame; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.sequence = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.stream = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.payload = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.elapsed.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.elapsed = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReplayFrame { + sequence: self.sequence, + stream: self.stream, + payload: self.payload.map(|b| (b).to_vec()), + elapsed: match self.elapsed.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReplayFrameView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.sequence) as u64; + { + let val = self.stream.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.payload { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.elapsed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.elapsed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.sequence, buf); + ::buffa::types::put_int32_field(2u32, self.stream.to_i32(), buf); + if let Some(ref v) = self.payload { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + if self.elapsed.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.elapsed.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReplayFrameView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "sequence", + &::buffa::json_helpers::ProtoJson(&self.sequence), + )?; + } + { + __map.serialize_entry("stream", &self.stream)?; + } + if let ::core::option::Option::Some(__v) = self.payload { + __map.serialize_entry("payload", &::buffa::json_helpers::BytesJson(__v))?; + } + { + if let ::core::option::Option::Some(__v) = self.elapsed.as_option() { + __map.serialize_entry("elapsed", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReplayFrameView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayFrame"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayFrame"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayFrame"; +} +::buffa::impl_default_view_instance!(ReplayFrameView); +::buffa::impl_view_reborrow!(ReplayFrameView); +/** Self-contained, `'static` owned view of a `ReplayFrame` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReplayFrameView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReplayFrameView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReplayFrameOwnedView(::buffa::OwnedView>); +impl ReplayFrameOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayFrameOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayFrameOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReplayFrame, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayFrameOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReplayFrameView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReplayFrameView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReplayFrame { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The capturer's own count, starting at 0, never compacted. + /// + /// When frames are dropped the surviving ones keep the numbers they were + /// given, so a gap in this sequence is a gap in the output. Renumbering to + /// stay contiguous would erase the only evidence inside the artifact that + /// anything is missing. + /// + /// Field 1: `sequence` + #[must_use] + pub fn sequence(&self) -> u64 { + self.0.reborrow().sequence + } + /// Field 2: `stream` + #[must_use] + pub fn stream(&self) -> ::buffa::EnumValue { + self.0.reborrow().stream + } + /// Raw bytes as captured. Not decoded, not normalized, and specifically not + /// stripped of control sequences: a terminal replay that removes them is + /// replaying something the terminal never showed. Decoding is the renderer's + /// job and is a decision it gets to make at render time, more than once. + /// + /// Field 3: `payload` + #[must_use] + pub fn payload(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().payload + } + /// Elapsed time from the start of capture to when the capturer observed this + /// frame. Present only when CommandOutputReplayRef.timing is + /// TIMING_FIDELITY_CAPTURE_ELAPSED, and unset on every frame otherwise. + /// + /// Field 4: `elapsed` + #[must_use] + pub fn elapsed( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().elapsed + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReplayFrameOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReplayFrameOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReplayFrameOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReplayFrameOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReplayFrame { + type View<'a> = ReplayFrameView<'a>; + type ViewHandle = ReplayFrameOwnedView; +} +impl ::serde::Serialize for ReplayFrameOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.rs new file mode 100644 index 0000000000..2764144eb1 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.frame.rs @@ -0,0 +1,400 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/replay/v1alpha1/frame.proto + +/// ReplayStream is which stream a frame came from. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ReplayStream { + REPLAY_STREAM_UNSPECIFIED = 0i32, + REPLAY_STREAM_STDOUT = 1i32, + REPLAY_STREAM_STDERR = 2i32, + /// Captured through one terminal or one pipe, where the two streams were + /// already indistinguishable before the capturer saw them. Every frame of a + /// CAPTURE_MODE_MERGED_TERMINAL artifact carries this. It means attribution is + /// unavailable, not that it is pending, and a renderer must not infer stderr + /// from content to fill it in. + REPLAY_STREAM_MERGED = 3i32, +} +impl ReplayStream { + ///Idiomatic alias for [`Self::REPLAY_STREAM_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::REPLAY_STREAM_UNSPECIFIED; + ///Idiomatic alias for [`Self::REPLAY_STREAM_STDOUT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Stdout: Self = Self::REPLAY_STREAM_STDOUT; + ///Idiomatic alias for [`Self::REPLAY_STREAM_STDERR`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Stderr: Self = Self::REPLAY_STREAM_STDERR; + ///Idiomatic alias for [`Self::REPLAY_STREAM_MERGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Merged: Self = Self::REPLAY_STREAM_MERGED; +} +impl ::core::default::Default for ReplayStream { + fn default() -> Self { + Self::REPLAY_STREAM_UNSPECIFIED + } +} +impl ::serde::Serialize for ReplayStream { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ReplayStream { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ReplayStream; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(ReplayStream)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReplayStream { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ReplayStream { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::REPLAY_STREAM_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::REPLAY_STREAM_STDOUT), + 2i32 => ::core::option::Option::Some(Self::REPLAY_STREAM_STDERR), + 3i32 => ::core::option::Option::Some(Self::REPLAY_STREAM_MERGED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::REPLAY_STREAM_UNSPECIFIED => "REPLAY_STREAM_UNSPECIFIED", + Self::REPLAY_STREAM_STDOUT => "REPLAY_STREAM_STDOUT", + Self::REPLAY_STREAM_STDERR => "REPLAY_STREAM_STDERR", + Self::REPLAY_STREAM_MERGED => "REPLAY_STREAM_MERGED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "REPLAY_STREAM_UNSPECIFIED" => { + ::core::option::Option::Some(Self::REPLAY_STREAM_UNSPECIFIED) + } + "REPLAY_STREAM_STDOUT" => { + ::core::option::Option::Some(Self::REPLAY_STREAM_STDOUT) + } + "REPLAY_STREAM_STDERR" => { + ::core::option::Option::Some(Self::REPLAY_STREAM_STDERR) + } + "REPLAY_STREAM_MERGED" => { + ::core::option::Option::Some(Self::REPLAY_STREAM_MERGED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::REPLAY_STREAM_UNSPECIFIED, + Self::REPLAY_STREAM_STDOUT, + Self::REPLAY_STREAM_STDERR, + Self::REPLAY_STREAM_MERGED, + ] + } +} +/// The byte layout of a command-output replay artifact, format version 1. +/// +/// An artifact is two regions. The frame region runs from offset 0 and holds +/// frames back to back, each one a little-endian uint32 byte length followed by +/// that many bytes of a serialized ReplayFrame. The index region is a trailer +/// holding a serialized ReplayIndex; its offset and length are recorded on the +/// log, in CommandOutputReplayRef. +/// +/// These types are defined here rather than on the write side because they +/// describe bytes a reader parses, not a field an event carries. The write side +/// records where the capture is and what it is worth; this is what is inside it, +/// and the two change for different reasons (ADR#0035 facet 3). +/// +/// ReplayFrame is one contiguous run of output the capturer read in one go. +/// +/// A frame boundary is a fact about the capturer's read loop and nothing else. +/// It is not a line, not a write() by the process, and not a flush. A renderer +/// that treats frames as lines will split a line that arrived in two reads, and +/// it will do it differently on a fast machine than a slow one. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReplayFrame { + /// The capturer's own count, starting at 0, never compacted. + /// + /// When frames are dropped the surviving ones keep the numbers they were + /// given, so a gap in this sequence is a gap in the output. Renumbering to + /// stay contiguous would erase the only evidence inside the artifact that + /// anything is missing. + /// + /// Field 1: `sequence` + #[serde(rename = "sequence", with = "::buffa::json_helpers::uint64")] + pub sequence: u64, + /// Field 2: `stream` + #[serde(rename = "stream", with = "::buffa::json_helpers::proto_enum")] + pub stream: ::buffa::EnumValue, + /// Raw bytes as captured. Not decoded, not normalized, and specifically not + /// stripped of control sequences: a terminal replay that removes them is + /// replaying something the terminal never showed. Decoding is the renderer's + /// job and is a decision it gets to make at render time, more than once. + /// + /// Field 3: `payload` + #[serde( + rename = "payload", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub payload: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Elapsed time from the start of capture to when the capturer observed this + /// frame. Present only when CommandOutputReplayRef.timing is + /// TIMING_FIDELITY_CAPTURE_ELAPSED, and unset on every frame otherwise. + /// + /// Field 4: `elapsed` + #[serde( + rename = "elapsed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub elapsed: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for ReplayFrame { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReplayFrame") + .field("sequence", &self.sequence) + .field("stream", &self.stream) + .field("payload", &self.payload) + .field("elapsed", &self.elapsed) + .finish() + } +} +impl ReplayFrame { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayFrame"; +} +impl ReplayFrame { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::payload`] to `Some(value)`, consuming and returning `self`. + pub fn with_payload( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.payload = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ReplayFrame); +impl ::buffa::MessageName for ReplayFrame { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayFrame"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayFrame"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayFrame"; +} +impl ::buffa::Message for ReplayFrame { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.sequence) as u64; + { + let val = self.stream.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.payload { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.elapsed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.elapsed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.sequence, buf); + ::buffa::types::put_int32_field(2u32, self.stream.to_i32(), buf); + if let Some(ref v) = self.payload { + ::buffa::types::put_shared_bytes_field(3u32, v, buf); + } + if self.elapsed.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.elapsed.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.sequence = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.stream = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self.payload.get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.elapsed.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence = 0u64; + self.stream = ::buffa::EnumValue::from(0); + self.payload = ::core::option::Option::None; + self.elapsed = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReplayFrame { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPLAY_FRAME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayFrame", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.__view.rs new file mode 100644 index 0000000000..31569df8f8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.__view.rs @@ -0,0 +1,805 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/replay/v1alpha1/index.proto + +/// ReplayIndex is the trailer that makes a bounded range read of a replay +/// artifact useful. +/// +/// Range reads are byte-granular and frames are variable-length, so a read into +/// the middle of the frame region lands mid-frame, with no way to tell from the +/// bytes where the next boundary is. Without an index the only correct way to +/// reach frame one million is to parse the previous 999,999, which is exactly +/// the cost that keeping the output out of the log was supposed to avoid. +/// +/// The index is sparse. It marks frame boundaries at intervals rather than every +/// frame, because an entry per frame is an index whose size grows with the +/// output it indexes, which is the problem again with more steps. A reader seeks +/// to the nearest preceding entry and scans forward a bounded distance. +#[derive(Clone, Debug, Default)] +pub struct ReplayIndexView<'a> { + /// Total frames in the capture, and total payload bytes across them. + /// + /// Both are also on the log, in CommandOutputReplayRef. The repetition is the + /// point: a reader that has fetched only this trailer can check it against the + /// event before trusting a single offset in it, and the event is the copy the + /// artifact store did not supply. An index that disagrees with the log is not + /// a stale index, it is the wrong artifact or a damaged one. + /// + /// Field 1: `frame_count` + pub frame_count: u64, + /// Field 2: `output_byte_count` + pub output_byte_count: u64, + /// Seek points in artifact order, always including a first entry at frame 0. + /// + /// The stride is the capturer's choice and is not recorded, because a reader + /// has no use for it: it binary-searches on whichever coordinate it is seeking + /// by, and a fixed stride would be a promise a capturer that stops early + /// cannot keep. + /// + /// Field 3: `entries` + pub entries: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::ReplayIndexEntryView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReplayIndexView<'a> { + /**Whether required field `frame_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_frame_count(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `output_byte_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_output_byte_count(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReplayIndexView<'a> { + type Owned = super::super::ReplayIndex; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.frame_count = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.output_byte_count = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::ReplayIndexEntryView, + >(), + )?; + view.entries + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReplayIndex { + frame_count: self.frame_count, + output_byte_count: self.output_byte_count, + entries: self + .entries + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReplayIndexView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_count) as u64; + for v in &self.entries { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.frame_count, buf); + ::buffa::types::put_uint64_field(2u32, self.output_byte_count, buf); + for v in &self.entries { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReplayIndexView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "frameCount", + &::buffa::json_helpers::ProtoJson(&self.frame_count), + )?; + } + { + __map + .serialize_entry( + "outputByteCount", + &::buffa::json_helpers::ProtoJson(&self.output_byte_count), + )?; + } + if !self.entries.is_empty() { + __map.serialize_entry("entries", &*self.entries)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReplayIndexView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayIndex"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayIndex"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndex"; +} +::buffa::impl_default_view_instance!(ReplayIndexView); +::buffa::impl_view_reborrow!(ReplayIndexView); +/** Self-contained, `'static` owned view of a `ReplayIndex` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReplayIndexView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReplayIndexView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReplayIndexOwnedView(::buffa::OwnedView>); +impl ReplayIndexOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReplayIndex, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReplayIndexView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReplayIndexView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReplayIndex { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Total frames in the capture, and total payload bytes across them. + /// + /// Both are also on the log, in CommandOutputReplayRef. The repetition is the + /// point: a reader that has fetched only this trailer can check it against the + /// event before trusting a single offset in it, and the event is the copy the + /// artifact store did not supply. An index that disagrees with the log is not + /// a stale index, it is the wrong artifact or a damaged one. + /// + /// Field 1: `frame_count` + #[must_use] + pub fn frame_count(&self) -> u64 { + self.0.reborrow().frame_count + } + /// Field 2: `output_byte_count` + #[must_use] + pub fn output_byte_count(&self) -> u64 { + self.0.reborrow().output_byte_count + } + /// Seek points in artifact order, always including a first entry at frame 0. + /// + /// The stride is the capturer's choice and is not recorded, because a reader + /// has no use for it: it binary-searches on whichever coordinate it is seeking + /// by, and a fixed stride would be a promise a capturer that stops early + /// cannot keep. + /// + /// Field 3: `entries` + #[must_use] + pub fn entries( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::ReplayIndexEntryView<'_>, + > { + &self.0.reborrow().entries + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReplayIndexOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReplayIndexOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReplayIndexOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReplayIndexOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReplayIndex { + type View<'a> = ReplayIndexView<'a>; + type ViewHandle = ReplayIndexOwnedView; +} +impl ::serde::Serialize for ReplayIndexOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReplayIndexEntry is one seek point, expressed in every coordinate a reader +/// might be seeking by. +/// +/// The three offsets are not redundant. They answer different questions, and a +/// reader converting between them would have to parse the frames to do it, which +/// is what it came here to avoid. +#[derive(Clone, Debug, Default)] +pub struct ReplayIndexEntryView<'a> { + /// Byte offset of a frame boundary, from the start of the artifact. This is + /// the value a range read takes. + /// + /// Field 1: `byte_offset` + pub byte_offset: u64, + /// Sequence of the frame at that boundary. Not the entry's position times a + /// stride: dropped frames leave gaps in the sequence, so this has to be + /// recorded. + /// + /// Field 2: `frame_sequence` + pub frame_sequence: u64, + /// Payload bytes emitted before that frame. This is what a UI scrolls and + /// measures in, since a user positions themselves in output, not in framing + /// overhead. + /// + /// Field 3: `output_byte_offset` + pub output_byte_offset: u64, + /// Elapsed time at that frame. Present only when the capture recorded timing, + /// and it is what makes seeking by time possible without reading anything. + /// + /// Field 4: `elapsed` + pub elapsed: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReplayIndexEntryView<'a> { + /**Whether required field `byte_offset` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_byte_offset(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `frame_sequence` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_frame_sequence(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `output_byte_offset` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_output_byte_offset(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReplayIndexEntryView<'a> { + type Owned = super::super::ReplayIndexEntry; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.byte_offset = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.frame_sequence = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.output_byte_offset = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.elapsed.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.elapsed = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReplayIndexEntry { + byte_offset: self.byte_offset, + frame_sequence: self.frame_sequence, + output_byte_offset: self.output_byte_offset, + elapsed: match self.elapsed.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReplayIndexEntryView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.byte_offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_sequence) as u64; + size + += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_offset) as u64; + if self.elapsed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.elapsed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.byte_offset, buf); + ::buffa::types::put_uint64_field(2u32, self.frame_sequence, buf); + ::buffa::types::put_uint64_field(3u32, self.output_byte_offset, buf); + if self.elapsed.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.elapsed.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReplayIndexEntryView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map + .serialize_entry( + "byteOffset", + &::buffa::json_helpers::ProtoJson(&self.byte_offset), + )?; + } + { + __map + .serialize_entry( + "frameSequence", + &::buffa::json_helpers::ProtoJson(&self.frame_sequence), + )?; + } + { + __map + .serialize_entry( + "outputByteOffset", + &::buffa::json_helpers::ProtoJson(&self.output_byte_offset), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.elapsed.as_option() { + __map.serialize_entry("elapsed", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReplayIndexEntryView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayIndexEntry"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry"; +} +::buffa::impl_default_view_instance!(ReplayIndexEntryView); +::buffa::impl_view_reborrow!(ReplayIndexEntryView); +/** Self-contained, `'static` owned view of a `ReplayIndexEntry` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReplayIndexEntryView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReplayIndexEntryView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReplayIndexEntryOwnedView(::buffa::OwnedView>); +impl ReplayIndexEntryOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexEntryOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexEntryOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReplayIndexEntry, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayIndexEntryOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReplayIndexEntryView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReplayIndexEntryView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReplayIndexEntry { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Byte offset of a frame boundary, from the start of the artifact. This is + /// the value a range read takes. + /// + /// Field 1: `byte_offset` + #[must_use] + pub fn byte_offset(&self) -> u64 { + self.0.reborrow().byte_offset + } + /// Sequence of the frame at that boundary. Not the entry's position times a + /// stride: dropped frames leave gaps in the sequence, so this has to be + /// recorded. + /// + /// Field 2: `frame_sequence` + #[must_use] + pub fn frame_sequence(&self) -> u64 { + self.0.reborrow().frame_sequence + } + /// Payload bytes emitted before that frame. This is what a UI scrolls and + /// measures in, since a user positions themselves in output, not in framing + /// overhead. + /// + /// Field 3: `output_byte_offset` + #[must_use] + pub fn output_byte_offset(&self) -> u64 { + self.0.reborrow().output_byte_offset + } + /// Elapsed time at that frame. Present only when the capture recorded timing, + /// and it is what makes seeking by time possible without reading anything. + /// + /// Field 4: `elapsed` + #[must_use] + pub fn elapsed( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().elapsed + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReplayIndexEntryOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReplayIndexEntryOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReplayIndexEntryOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReplayIndexEntryOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReplayIndexEntry { + type View<'a> = ReplayIndexEntryView<'a>; + type ViewHandle = ReplayIndexEntryOwnedView; +} +impl ::serde::Serialize for ReplayIndexEntryOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.rs new file mode 100644 index 0000000000..bf22af7d41 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.index.rs @@ -0,0 +1,393 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/replay/v1alpha1/index.proto + +/// ReplayIndex is the trailer that makes a bounded range read of a replay +/// artifact useful. +/// +/// Range reads are byte-granular and frames are variable-length, so a read into +/// the middle of the frame region lands mid-frame, with no way to tell from the +/// bytes where the next boundary is. Without an index the only correct way to +/// reach frame one million is to parse the previous 999,999, which is exactly +/// the cost that keeping the output out of the log was supposed to avoid. +/// +/// The index is sparse. It marks frame boundaries at intervals rather than every +/// frame, because an entry per frame is an index whose size grows with the +/// output it indexes, which is the problem again with more steps. A reader seeks +/// to the nearest preceding entry and scans forward a bounded distance. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReplayIndex { + /// Total frames in the capture, and total payload bytes across them. + /// + /// Both are also on the log, in CommandOutputReplayRef. The repetition is the + /// point: a reader that has fetched only this trailer can check it against the + /// event before trusting a single offset in it, and the event is the copy the + /// artifact store did not supply. An index that disagrees with the log is not + /// a stale index, it is the wrong artifact or a damaged one. + /// + /// Field 1: `frame_count` + #[serde( + rename = "frameCount", + alias = "frame_count", + with = "::buffa::json_helpers::uint64" + )] + pub frame_count: u64, + /// Field 2: `output_byte_count` + #[serde( + rename = "outputByteCount", + alias = "output_byte_count", + with = "::buffa::json_helpers::uint64" + )] + pub output_byte_count: u64, + /// Seek points in artifact order, always including a first entry at frame 0. + /// + /// The stride is the capturer's choice and is not recorded, because a reader + /// has no use for it: it binary-searches on whichever coordinate it is seeking + /// by, and a fixed stride would be a promise a capturer that stops early + /// cannot keep. + /// + /// Field 3: `entries` + #[serde( + rename = "entries", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub entries: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ReplayIndex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReplayIndex") + .field("frame_count", &self.frame_count) + .field("output_byte_count", &self.output_byte_count) + .field("entries", &self.entries) + .finish() + } +} +impl ReplayIndex { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndex"; +} +::buffa::impl_default_instance!(ReplayIndex); +impl ::buffa::MessageName for ReplayIndex { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayIndex"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayIndex"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndex"; +} +impl ::buffa::Message for ReplayIndex { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_count) as u64; + for v in &self.entries { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.frame_count, buf); + ::buffa::types::put_uint64_field(2u32, self.output_byte_count, buf); + for v in &self.entries { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.frame_count = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.output_byte_count = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.entries.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.frame_count = 0u64; + self.output_byte_count = 0u64; + self.entries.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReplayIndex { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPLAY_INDEX_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndex", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReplayIndexEntry is one seek point, expressed in every coordinate a reader +/// might be seeking by. +/// +/// The three offsets are not redundant. They answer different questions, and a +/// reader converting between them would have to parse the frames to do it, which +/// is what it came here to avoid. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReplayIndexEntry { + /// Byte offset of a frame boundary, from the start of the artifact. This is + /// the value a range read takes. + /// + /// Field 1: `byte_offset` + #[serde( + rename = "byteOffset", + alias = "byte_offset", + with = "::buffa::json_helpers::uint64" + )] + pub byte_offset: u64, + /// Sequence of the frame at that boundary. Not the entry's position times a + /// stride: dropped frames leave gaps in the sequence, so this has to be + /// recorded. + /// + /// Field 2: `frame_sequence` + #[serde( + rename = "frameSequence", + alias = "frame_sequence", + with = "::buffa::json_helpers::uint64" + )] + pub frame_sequence: u64, + /// Payload bytes emitted before that frame. This is what a UI scrolls and + /// measures in, since a user positions themselves in output, not in framing + /// overhead. + /// + /// Field 3: `output_byte_offset` + #[serde( + rename = "outputByteOffset", + alias = "output_byte_offset", + with = "::buffa::json_helpers::uint64" + )] + pub output_byte_offset: u64, + /// Elapsed time at that frame. Present only when the capture recorded timing, + /// and it is what makes seeking by time possible without reading anything. + /// + /// Field 4: `elapsed` + #[serde( + rename = "elapsed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub elapsed: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, +} +impl ::core::fmt::Debug for ReplayIndexEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReplayIndexEntry") + .field("byte_offset", &self.byte_offset) + .field("frame_sequence", &self.frame_sequence) + .field("output_byte_offset", &self.output_byte_offset) + .field("elapsed", &self.elapsed) + .finish() + } +} +impl ReplayIndexEntry { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry"; +} +::buffa::impl_default_instance!(ReplayIndexEntry); +impl ::buffa::MessageName for ReplayIndexEntry { + const PACKAGE: &'static str = "trogonai.session.sessions.replay.v1alpha1"; + const NAME: &'static str = "ReplayIndexEntry"; + const FULL_NAME: &'static str = "trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry"; +} +impl ::buffa::Message for ReplayIndexEntry { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.byte_offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_sequence) as u64; + size + += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_offset) as u64; + if self.elapsed.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.elapsed.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_uint64_field(1u32, self.byte_offset, buf); + ::buffa::types::put_uint64_field(2u32, self.frame_sequence, buf); + ::buffa::types::put_uint64_field(3u32, self.output_byte_offset, buf); + if self.elapsed.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.elapsed.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.byte_offset = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.frame_sequence = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.output_byte_offset = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.elapsed.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.byte_offset = 0u64; + self.frame_sequence = 0u64; + self.output_byte_offset = 0u64; + self.elapsed = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReplayIndexEntry { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPLAY_INDEX_ENTRY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.replay.v1alpha1.ReplayIndexEntry", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.mod.rs new file mode 100644 index 0000000000..8770c2c34c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.replay.v1alpha1.mod.rs @@ -0,0 +1,45 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.replay.v1alpha1.frame.rs"); +include!("trogonai.session.sessions.replay.v1alpha1.index.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.replay.v1alpha1.frame.__view.rs"); + include!("trogonai.session.sessions.replay.v1alpha1.index.__view.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__REPLAY_FRAME_JSON_ANY); + reg.register_json_any(super::__REPLAY_INDEX_JSON_ANY); + reg.register_json_any(super::__REPLAY_INDEX_ENTRY_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::ReplayFrameView; +#[doc(inline)] +pub use self::__buffa::view::ReplayFrameOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReplayIndexView; +#[doc(inline)] +pub use self::__buffa::view::ReplayIndexOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReplayIndexEntryView; +#[doc(inline)] +pub use self::__buffa::view::ReplayIndexEntryOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.mod.rs new file mode 100644 index 0000000000..b657451a6c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.mod.rs @@ -0,0 +1,78 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.session.sessions.state.v1alpha1.state.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!("trogonai.session.sessions.state.v1alpha1.state.__view.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__STATE_JSON_ANY); + reg.register_json_any(super::__FORK_ORIGIN_JSON_ANY); + reg.register_json_any(super::__RECOVERY_ORIGIN_JSON_ANY); + reg.register_json_any(super::__PARENT_LINK_JSON_ANY); + reg.register_json_any(super::__DELEGATION_JSON_ANY); + reg.register_json_any(super::__EXECUTION_ATTEMPT_JSON_ANY); + reg.register_json_any(super::__COMPACTION_MARKER_JSON_ANY); + reg.register_json_any(super::__TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__OPERATION_JSON_ANY); + reg.register_json_any(super::__CHECKPOINT_EVIDENCE_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::StateView; +#[doc(inline)] +pub use self::__buffa::view::StateOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ForkOriginView; +#[doc(inline)] +pub use self::__buffa::view::ForkOriginOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecoveryOriginView; +#[doc(inline)] +pub use self::__buffa::view::RecoveryOriginOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ParentLinkView; +#[doc(inline)] +pub use self::__buffa::view::ParentLinkOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DelegationView; +#[doc(inline)] +pub use self::__buffa::view::DelegationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ExecutionAttemptView; +#[doc(inline)] +pub use self::__buffa::view::ExecutionAttemptOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CompactionMarkerView; +#[doc(inline)] +pub use self::__buffa::view::CompactionMarkerOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ToolCallView; +#[doc(inline)] +pub use self::__buffa::view::ToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::OperationView; +#[doc(inline)] +pub use self::__buffa::view::OperationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CheckpointEvidenceView; +#[doc(inline)] +pub use self::__buffa::view::CheckpointEvidenceOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.__view.rs new file mode 100644 index 0000000000..38a04b936d --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.__view.rs @@ -0,0 +1,5623 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/state/v1alpha1/state.proto + +/// State is the Session aggregate's write-side fold: exactly the facts the +/// session commands read to enforce their invariants, and nothing a read model +/// owns (ADR#0035, ADR#0045). It is never a projection and never a transcript; +/// message bodies, todo items, artifacts, and display metadata are deliberately +/// absent because no command reads them. +/// +/// A crash between a started tool call and its outcome is the load-bearing case: +/// replaying a session leaves that call in TOOL_CALL_STATUS_STARTED with no +/// settled_at, and its reserved operation in OPERATION_STATUS_RESERVED, so +/// reconciliation can see the missing terminal outcome and finish or reject the +/// interrupted call rather than silently dropping it. +#[derive(Clone, Debug, Default)] +pub struct StateView<'a> { + /// Field 1: `state` + pub state: ::buffa::EnumValue, + /// Field 2: `session_id` + pub session_id: &'a str, + /// Count of events folded so far: this session's own fold-derived ordinal of + /// the last applied event, never a JetStream sequence (ADR#0013). + /// + /// Field 3: `position` + pub position: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Digest of the immutable StoredSessionExecutionPlan recorded at start; every + /// attempt, checkpoint, and compaction is bound to it. + /// + /// Field 4: `execution_plan_digest` + pub execution_plan_digest: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'a>, + >, + /// Which marker sealed the session. The first terminal marker wins; a later one + /// is audit-only. + /// + /// Field 5: `terminal_marker` + pub terminal_marker: ::buffa::EnumValue, + /// Context root when this session was forked from another one; unset for a + /// session that started its own context. + /// + /// Field 6: `fork_origin` + pub fork_origin: ::buffa::MessageFieldView< + super::super::__buffa::view::ForkOriginView<'a>, + >, + /// Provenance of a salvaged session; unset for a session that was not + /// recovered from a damaged source. Folded because it is a precondition the + /// commands must be able to read: a session that is a partial copy cannot + /// honor a rewind or a compaction against source positions it never received. + /// + /// Field 19: `recovery_origin` + pub recovery_origin: ::buffa::MessageFieldView< + super::super::__buffa::view::RecoveryOriginView<'a>, + >, + /// Recorded parent lineage of a delegated child session. + /// + /// Field 7: `parent` + pub parent: ::buffa::MessageFieldView< + super::super::__buffa::view::ParentLinkView<'a>, + >, + /// Newest rewind boundary. Rewind masks effective history for readers and + /// future turns; it never un-applies folded facts, because a tool call that + /// really ran still has to be reconcilable. + /// + /// Field 8: `keep_through` + pub keep_through: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Newest compaction marker, the prior usable boundary a further compaction + /// and an attempt restore both resolve against. + /// + /// Field 9: `compaction` + pub compaction: ::buffa::MessageFieldView< + super::super::__buffa::view::CompactionMarkerView<'a>, + >, + /// Attempt currently holding the session; unset when no attempt is running. + /// + /// Field 10: `active_attempt` + pub active_attempt: ::buffa::MessageFieldView< + super::super::__buffa::view::ExecutionAttemptView<'a>, + >, + /// Most recently started attempt, still active or already ended, so a new + /// attempt can be checked for monotonic numbering and exact predecessor. + /// + /// Field 11: `last_attempt_id` + pub last_attempt_id: ::core::option::Option<&'a str>, + /// Field 12: `last_attempt_number` + pub last_attempt_number: ::core::option::Option, + /// Tool calls keyed by tool_call_id, in first-observed fold order. + /// + /// Field 13: `tool_calls` + pub tool_calls: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::ToolCallView<'a>, + >, + /// Operation ledger entries keyed by operation_id, in reservation fold order. + /// + /// Field 14: `operations` + pub operations: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::OperationView<'a>, + >, + /// Dispatched delegations keyed by operation_id, parent side. + /// + /// Field 15: `delegations` + pub delegations: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::DelegationView<'a>, + >, + /// First admitted evidence per checkpoint_id; a later event reusing an id is + /// retained on the log but never replaces the admitted evidence. + /// + /// Field 16: `checkpoints` + pub checkpoints: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::CheckpointEvidenceView<'a>, + >, + /// Privacy dependencies an attempt restore and a compaction must respect. + /// + /// Field 17: `redacted_event_ids` + pub redacted_event_ids: ::buffa::RepeatedView<'a, &'a str>, + /// Field 18: `erased_artifact_ids` + pub erased_artifact_ids: ::buffa::RepeatedView<'a, &'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StateView<'a> { + /**Whether required field `state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_state(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `position` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_position(&self) -> bool { + self.position.is_set() + } + /**Whether required field `terminal_marker` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_terminal_marker(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StateView<'a> { + type Owned = super::super::State; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.position.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.position = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.execution_plan_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.execution_plan_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.terminal_marker = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.fork_origin.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.fork_origin = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 19u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.recovery_origin.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.recovery_origin = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.parent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.parent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.keep_through.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.keep_through = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.compaction.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.compaction = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.active_attempt.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.active_attempt = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.last_attempt_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.last_attempt_number = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.tool_calls + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 14u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.operations + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 15u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.delegations + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 16u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::CheckpointEvidenceView, + >(), + )?; + view.checkpoints + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 17u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::borrow_str(&mut cur)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + view.redacted_event_ids.push(__elem); + } + 18u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::borrow_str(&mut cur)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + view.erased_artifact_ids.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::State { + state: self.state, + session_id: self.session_id.to_string(), + position: match self.position.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + execution_plan_digest: match self.execution_plan_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + terminal_marker: self.terminal_marker, + fork_origin: match self.fork_origin.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ForkOrigin, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + recovery_origin: match self.recovery_origin.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::RecoveryOrigin, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + parent: match self.parent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ParentLink, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + keep_through: match self.keep_through.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + compaction: match self.compaction.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CompactionMarker, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + active_attempt: match self.active_attempt.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ExecutionAttempt, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + last_attempt_id: self.last_attempt_id.map(|s| s.to_string()), + last_attempt_number: self.last_attempt_number, + tool_calls: self + .tool_calls + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + operations: self + .operations + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + delegations: self + .delegations + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + checkpoints: self + .checkpoints + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + redacted_event_ids: self + .redacted_event_ids + .iter() + .map(|s| s.to_string()) + .collect(), + erased_artifact_ids: self + .erased_artifact_ids + .iter() + .map(|s| s.to_string()) + .collect(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StateView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.position.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.position.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.execution_plan_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.terminal_marker.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.fork_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fork_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.parent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.compaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.active_attempt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.active_attempt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.last_attempt_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.last_attempt_number { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + for v in &self.tool_calls { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.operations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.delegations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.checkpoints { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 2u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.redacted_event_ids { + size += 2u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.erased_artifact_ids { + size += 2u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.recovery_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.recovery_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 2u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.state.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.session_id, buf); + if self.position.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.position.write_to(__cache, buf); + } + if self.execution_plan_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(5u32, self.terminal_marker.to_i32(), buf); + if self.fork_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.fork_origin.write_to(__cache, buf); + } + if self.parent.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent.write_to(__cache, buf); + } + if self.keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.keep_through.write_to(__cache, buf); + } + if self.compaction.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compaction.write_to(__cache, buf); + } + if self.active_attempt.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.active_attempt.write_to(__cache, buf); + } + if let Some(ref v) = self.last_attempt_id { + ::buffa::types::put_string_field(11u32, v, buf); + } + if let Some(v) = self.last_attempt_number { + ::buffa::types::put_uint64_field(12u32, v, buf); + } + for v in &self.tool_calls { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.operations { + ::buffa::types::put_len_delimited_header( + 14u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.delegations { + ::buffa::types::put_len_delimited_header( + 15u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.checkpoints { + ::buffa::types::put_len_delimited_header( + 16u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.redacted_event_ids { + ::buffa::types::put_string_field(17u32, v, buf); + } + for v in &self.erased_artifact_ids { + ::buffa::types::put_string_field(18u32, v, buf); + } + if self.recovery_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 19u32, + u64::from(__cache.consume_next()), + buf, + ); + self.recovery_origin.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StateView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("state", &self.state)?; + } + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.position.as_option() { + __map.serialize_entry("position", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .execution_plan_digest + .as_option() + { + __map.serialize_entry("executionPlanDigest", __v)?; + } + } + { + __map.serialize_entry("terminalMarker", &self.terminal_marker)?; + } + { + if let ::core::option::Option::Some(__v) = self.fork_origin.as_option() { + __map.serialize_entry("forkOrigin", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.recovery_origin.as_option() { + __map.serialize_entry("recoveryOrigin", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.parent.as_option() { + __map.serialize_entry("parent", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.keep_through.as_option() { + __map.serialize_entry("keepThrough", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.compaction.as_option() { + __map.serialize_entry("compaction", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.active_attempt.as_option() { + __map.serialize_entry("activeAttempt", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.last_attempt_id { + __map.serialize_entry("lastAttemptId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.last_attempt_number { + __map + .serialize_entry( + "lastAttemptNumber", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if !self.tool_calls.is_empty() { + __map.serialize_entry("toolCalls", &*self.tool_calls)?; + } + if !self.operations.is_empty() { + __map.serialize_entry("operations", &*self.operations)?; + } + if !self.delegations.is_empty() { + __map.serialize_entry("delegations", &*self.delegations)?; + } + if !self.checkpoints.is_empty() { + __map.serialize_entry("checkpoints", &*self.checkpoints)?; + } + if !self.redacted_event_ids.is_empty() { + __map.serialize_entry("redactedEventIds", &*self.redacted_event_ids)?; + } + if !self.erased_artifact_ids.is_empty() { + __map.serialize_entry("erasedArtifactIds", &*self.erased_artifact_ids)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StateView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "State"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.State"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.State"; +} +::buffa::impl_default_view_instance!(StateView); +::buffa::impl_view_reborrow!(StateView); +/** Self-contained, `'static` owned view of a `State` message. + + Wraps [`::buffa::OwnedView`]`<`[`StateView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StateView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StateOwnedView(::buffa::OwnedView>); +impl StateOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(StateOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StateOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::State, + ) -> ::core::result::Result { + ::core::result::Result::Ok(StateOwnedView(::buffa::OwnedView::from_owned(msg)?)) + } + /// Borrow the full [`StateView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StateView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::State { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `state` + #[must_use] + pub fn state(&self) -> ::buffa::EnumValue { + self.0.reborrow().state + } + /// Field 2: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Count of events folded so far: this session's own fold-derived ordinal of + /// the last applied event, never a JetStream sequence (ADR#0013). + /// + /// Field 3: `position` + #[must_use] + pub fn position( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().position + } + /// Digest of the immutable StoredSessionExecutionPlan recorded at start; every + /// attempt, checkpoint, and compaction is bound to it. + /// + /// Field 4: `execution_plan_digest` + #[must_use] + pub fn execution_plan_digest( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'_>, + > { + &self.0.reborrow().execution_plan_digest + } + /// Which marker sealed the session. The first terminal marker wins; a later one + /// is audit-only. + /// + /// Field 5: `terminal_marker` + #[must_use] + pub fn terminal_marker(&self) -> ::buffa::EnumValue { + self.0.reborrow().terminal_marker + } + /// Context root when this session was forked from another one; unset for a + /// session that started its own context. + /// + /// Field 6: `fork_origin` + #[must_use] + pub fn fork_origin( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().fork_origin + } + /// Provenance of a salvaged session; unset for a session that was not + /// recovered from a damaged source. Folded because it is a precondition the + /// commands must be able to read: a session that is a partial copy cannot + /// honor a rewind or a compaction against source positions it never received. + /// + /// Field 19: `recovery_origin` + #[must_use] + pub fn recovery_origin( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::RecoveryOriginView<'_>, + > { + &self.0.reborrow().recovery_origin + } + /// Recorded parent lineage of a delegated child session. + /// + /// Field 7: `parent` + #[must_use] + pub fn parent( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().parent + } + /// Newest rewind boundary. Rewind masks effective history for readers and + /// future turns; it never un-applies folded facts, because a tool call that + /// really ran still has to be reconcilable. + /// + /// Field 8: `keep_through` + #[must_use] + pub fn keep_through( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().keep_through + } + /// Newest compaction marker, the prior usable boundary a further compaction + /// and an attempt restore both resolve against. + /// + /// Field 9: `compaction` + #[must_use] + pub fn compaction( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CompactionMarkerView<'_>, + > { + &self.0.reborrow().compaction + } + /// Attempt currently holding the session; unset when no attempt is running. + /// + /// Field 10: `active_attempt` + #[must_use] + pub fn active_attempt( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ExecutionAttemptView<'_>, + > { + &self.0.reborrow().active_attempt + } + /// Most recently started attempt, still active or already ended, so a new + /// attempt can be checked for monotonic numbering and exact predecessor. + /// + /// Field 11: `last_attempt_id` + #[must_use] + pub fn last_attempt_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().last_attempt_id + } + /// Field 12: `last_attempt_number` + #[must_use] + pub fn last_attempt_number(&self) -> ::core::option::Option { + self.0.reborrow().last_attempt_number + } + /// Tool calls keyed by tool_call_id, in first-observed fold order. + /// + /// Field 13: `tool_calls` + #[must_use] + pub fn tool_calls( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::ToolCallView<'_>> { + &self.0.reborrow().tool_calls + } + /// Operation ledger entries keyed by operation_id, in reservation fold order. + /// + /// Field 14: `operations` + #[must_use] + pub fn operations( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OperationView<'_>> { + &self.0.reborrow().operations + } + /// Dispatched delegations keyed by operation_id, parent side. + /// + /// Field 15: `delegations` + #[must_use] + pub fn delegations( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::DelegationView<'_>> { + &self.0.reborrow().delegations + } + /// First admitted evidence per checkpoint_id; a later event reusing an id is + /// retained on the log but never replaces the admitted evidence. + /// + /// Field 16: `checkpoints` + #[must_use] + pub fn checkpoints( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::CheckpointEvidenceView<'_>, + > { + &self.0.reborrow().checkpoints + } + /// Privacy dependencies an attempt restore and a compaction must respect. + /// + /// Field 17: `redacted_event_ids` + #[must_use] + pub fn redacted_event_ids(&self) -> &::buffa::RepeatedView<'_, &'_ str> { + &self.0.reborrow().redacted_event_ids + } + /// Field 18: `erased_artifact_ids` + #[must_use] + pub fn erased_artifact_ids(&self) -> &::buffa::RepeatedView<'_, &'_ str> { + &self.0.reborrow().erased_artifact_ids + } +} +impl ::core::convert::From<::buffa::OwnedView>> for StateOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StateOwnedView(inner) + } +} +impl ::core::convert::From for ::buffa::OwnedView> { + fn from(wrapper: StateOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> for StateOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::State { + type View<'a> = StateView<'a>; + type ViewHandle = StateOwnedView; +} +impl ::serde::Serialize for StateOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct ForkOriginView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// Field 2: `context_prefix_boundary` + pub context_prefix_boundary: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ForkOriginView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `context_prefix_boundary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_context_prefix_boundary(&self) -> bool { + self.context_prefix_boundary.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ForkOriginView<'a> { + type Owned = super::super::ForkOrigin; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.context_prefix_boundary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.context_prefix_boundary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ForkOrigin { + source_session_id: self.source_session_id.to_string(), + context_prefix_boundary: match self.context_prefix_boundary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ForkOriginView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.context_prefix_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_prefix_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + if self.context_prefix_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_prefix_boundary.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ForkOriginView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .context_prefix_boundary + .as_option() + { + __map.serialize_entry("contextPrefixBoundary", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ForkOriginView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ForkOrigin"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ForkOrigin"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ForkOrigin"; +} +::buffa::impl_default_view_instance!(ForkOriginView); +::buffa::impl_view_reborrow!(ForkOriginView); +/** Self-contained, `'static` owned view of a `ForkOrigin` message. + + Wraps [`::buffa::OwnedView`]`<`[`ForkOriginView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ForkOriginView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ForkOriginOwnedView(::buffa::OwnedView>); +impl ForkOriginOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ForkOrigin, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkOriginOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ForkOriginView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ForkOriginView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ForkOrigin { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// Field 2: `context_prefix_boundary` + #[must_use] + pub fn context_prefix_boundary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().context_prefix_boundary + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ForkOriginOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ForkOriginOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ForkOriginOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ForkOriginOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ForkOrigin { + type View<'a> = ForkOriginView<'a>; + type ViewHandle = ForkOriginOwnedView; +} +impl ::serde::Serialize for ForkOriginOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// RecoveryOrigin is the damaged source a salvaged session was copied from. +/// +/// source_boundary is a position on the source's stream, not on this one. This +/// session's ordinals count its own events and start at 1 regardless of where the +/// source's cut ended. +#[derive(Clone, Debug, Default)] +pub struct RecoveryOriginView<'a> { + /// Field 1: `source_session_id` + pub source_session_id: &'a str, + /// Field 2: `source_boundary` + pub source_boundary: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 3: `source_digest` + pub source_digest: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'a>, + >, + /// Field 4: `salvage_key` + pub salvage_key: &'a str, + /// Field 5: `completeness` + pub completeness: ::buffa::EnumValue< + super::super::super::super::v1alpha1::RecoveryCompleteness, + >, + /// Field 6: `omitted_count` + pub omitted_count: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecoveryOriginView<'a> { + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `source_boundary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_boundary(&self) -> bool { + self.source_boundary.is_set() + } + /**Whether required field `source_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_digest(&self) -> bool { + self.source_digest.is_set() + } + /**Whether required field `salvage_key` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_salvage_key(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `completeness` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `omitted_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_omitted_count(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecoveryOriginView<'a> { + type Owned = super::super::RecoveryOrigin; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_boundary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_boundary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.salvage_key = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.omitted_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecoveryOrigin { + source_session_id: self.source_session_id.to_string(), + source_boundary: match self.source_boundary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_digest: match self.source_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + salvage_key: self.salvage_key.to_string(), + completeness: self.completeness, + omitted_count: self.omitted_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecoveryOriginView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(5u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(6u32, self.omitted_count, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecoveryOriginView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.source_boundary.as_option() { + __map.serialize_entry("sourceBoundary", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.source_digest.as_option() { + __map.serialize_entry("sourceDigest", __v)?; + } + } + { + __map.serialize_entry("salvageKey", self.salvage_key)?; + } + { + __map.serialize_entry("completeness", &self.completeness)?; + } + { + __map + .serialize_entry( + "omittedCount", + &::buffa::json_helpers::ProtoJson(&self.omitted_count), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecoveryOriginView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "RecoveryOrigin"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.RecoveryOrigin"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.RecoveryOrigin"; +} +::buffa::impl_default_view_instance!(RecoveryOriginView); +::buffa::impl_view_reborrow!(RecoveryOriginView); +/** Self-contained, `'static` owned view of a `RecoveryOrigin` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecoveryOriginView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecoveryOriginView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecoveryOriginOwnedView(::buffa::OwnedView>); +impl RecoveryOriginOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryOriginOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryOriginOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecoveryOrigin, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoveryOriginOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecoveryOriginView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecoveryOriginView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecoveryOrigin { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// Field 2: `source_boundary` + #[must_use] + pub fn source_boundary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().source_boundary + } + /// Field 3: `source_digest` + #[must_use] + pub fn source_digest( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'_>, + > { + &self.0.reborrow().source_digest + } + /// Field 4: `salvage_key` + #[must_use] + pub fn salvage_key(&self) -> &'_ str { + self.0.reborrow().salvage_key + } + /// Field 5: `completeness` + #[must_use] + pub fn completeness( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().completeness + } + /// Field 6: `omitted_count` + #[must_use] + pub fn omitted_count(&self) -> u32 { + self.0.reborrow().omitted_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecoveryOriginOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecoveryOriginOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecoveryOriginOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecoveryOriginOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecoveryOrigin { + type View<'a> = RecoveryOriginView<'a>; + type ViewHandle = RecoveryOriginOwnedView; +} +impl ::serde::Serialize for RecoveryOriginOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct ParentLinkView<'a> { + /// Field 1: `parent_session_id` + pub parent_session_id: &'a str, + /// The parent's own ordinal of the dispatch that created this session. + /// + /// Field 2: `parent_dispatched_at` + pub parent_dispatched_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 3: `cascade_policy` + pub cascade_policy: ::buffa::EnumValue< + super::super::super::super::v1alpha1::CascadePolicy, + >, + /// The parent-side operation this session was dispatched under. + /// + /// Field 4: `operation_id` + pub operation_id: &'a str, + /// The parent reached a terminal state and this session observed it. + /// + /// Field 5: `parent_terminated` + pub parent_terminated: bool, + /// The parent rewound past the dispatch: the inherited prefix no longer holds. + /// + /// Field 6: `history_invalidated` + pub history_invalidated: bool, + /// Set once the lineage is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + pub detach_operation_id: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ParentLinkView<'a> { + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `parent_dispatched_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_dispatched_at(&self) -> bool { + self.parent_dispatched_at.is_set() + } + /**Whether required field `cascade_policy` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_cascade_policy(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `parent_terminated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_terminated(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `history_invalidated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_history_invalidated(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ParentLinkView<'a> { + type Owned = super::super::ParentLink; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.parent_dispatched_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.parent_dispatched_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.parent_terminated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.history_invalidated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detach_operation_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ParentLink { + parent_session_id: self.parent_session_id.to_string(), + parent_dispatched_at: match self.parent_dispatched_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + cascade_policy: self.cascade_policy, + operation_id: self.operation_id.to_string(), + parent_terminated: self.parent_terminated, + history_invalidated: self.history_invalidated, + detach_operation_id: self.detach_operation_id.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ParentLinkView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if let Some(ref v) = self.detach_operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.parent_session_id, buf); + if self.parent_dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_dispatched_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.cascade_policy.to_i32(), buf); + ::buffa::types::put_string_field(4u32, &self.operation_id, buf); + ::buffa::types::put_bool_field(5u32, self.parent_terminated, buf); + ::buffa::types::put_bool_field(6u32, self.history_invalidated, buf); + if let Some(ref v) = self.detach_operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ParentLinkView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .parent_dispatched_at + .as_option() + { + __map.serialize_entry("parentDispatchedAt", __v)?; + } + } + { + __map.serialize_entry("cascadePolicy", &self.cascade_policy)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("parentTerminated", &self.parent_terminated)?; + } + { + __map.serialize_entry("historyInvalidated", &self.history_invalidated)?; + } + if let ::core::option::Option::Some(__v) = self.detach_operation_id { + __map.serialize_entry("detachOperationId", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ParentLinkView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ParentLink"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ParentLink"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ParentLink"; +} +::buffa::impl_default_view_instance!(ParentLinkView); +::buffa::impl_view_reborrow!(ParentLinkView); +/** Self-contained, `'static` owned view of a `ParentLink` message. + + Wraps [`::buffa::OwnedView`]`<`[`ParentLinkView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ParentLinkView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ParentLinkOwnedView(::buffa::OwnedView>); +impl ParentLinkOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentLinkOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentLinkOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ParentLink, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ParentLinkOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ParentLinkView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ParentLinkView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ParentLink { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// The parent's own ordinal of the dispatch that created this session. + /// + /// Field 2: `parent_dispatched_at` + #[must_use] + pub fn parent_dispatched_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().parent_dispatched_at + } + /// Field 3: `cascade_policy` + #[must_use] + pub fn cascade_policy( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().cascade_policy + } + /// The parent-side operation this session was dispatched under. + /// + /// Field 4: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// The parent reached a terminal state and this session observed it. + /// + /// Field 5: `parent_terminated` + #[must_use] + pub fn parent_terminated(&self) -> bool { + self.0.reborrow().parent_terminated + } + /// The parent rewound past the dispatch: the inherited prefix no longer holds. + /// + /// Field 6: `history_invalidated` + #[must_use] + pub fn history_invalidated(&self) -> bool { + self.0.reborrow().history_invalidated + } + /// Set once the lineage is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + #[must_use] + pub fn detach_operation_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detach_operation_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ParentLinkOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ParentLinkOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ParentLinkOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ParentLinkOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ParentLink { + type View<'a> = ParentLinkView<'a>; + type ViewHandle = ParentLinkOwnedView; +} +impl ::serde::Serialize for ParentLinkOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct DelegationView<'a> { + /// Field 1: `operation_id` + pub operation_id: &'a str, + /// Field 2: `kind` + pub kind: ::buffa::EnumValue, + /// Set for DELEGATION_KIND_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + pub child_session_id: ::core::option::Option<&'a str>, + /// Field 4: `cascade_policy` + pub cascade_policy: ::core::option::Option< + ::buffa::EnumValue, + >, + /// Set for DELEGATION_KIND_EXTERNAL. + /// + /// Field 5: `delegate_reference` + pub delegate_reference: ::core::option::Option<&'a str>, + /// Field 6: `dispatched_at` + pub dispatched_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Set once the child is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + pub detach_operation_id: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DelegationView<'a> { + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `dispatched_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_dispatched_at(&self) -> bool { + self.dispatched_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for DelegationView<'a> { + type Owned = super::super::Delegation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.child_session_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cascade_policy = Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(&mut cur)?), + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.delegate_reference = Some(::buffa::types::borrow_str(&mut cur)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.dispatched_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.dispatched_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detach_operation_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::Delegation { + operation_id: self.operation_id.to_string(), + kind: self.kind, + child_session_id: self.child_session_id.map(|s| s.to_string()), + cascade_policy: self.cascade_policy, + delegate_reference: self.delegate_reference.map(|s| s.to_string()), + dispatched_at: match self.dispatched_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detach_operation_id: self.detach_operation_id.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DelegationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.child_session_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.cascade_policy { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if let Some(ref v) = self.delegate_reference { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detach_operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.child_session_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.cascade_policy { + ::buffa::types::put_int32_field(4u32, v.to_i32(), buf); + } + if let Some(ref v) = self.delegate_reference { + ::buffa::types::put_string_field(5u32, v, buf); + } + if self.dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.dispatched_at.write_to(__cache, buf); + } + if let Some(ref v) = self.detach_operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DelegationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + if let ::core::option::Option::Some(__v) = self.child_session_id { + __map.serialize_entry("childSessionId", __v)?; + } + if let ::core::option::Option::Some(ref __v) = self.cascade_policy { + __map.serialize_entry("cascadePolicy", __v)?; + } + if let ::core::option::Option::Some(__v) = self.delegate_reference { + __map.serialize_entry("delegateReference", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.dispatched_at.as_option() { + __map.serialize_entry("dispatchedAt", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.detach_operation_id { + __map.serialize_entry("detachOperationId", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DelegationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "Delegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.Delegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Delegation"; +} +::buffa::impl_default_view_instance!(DelegationView); +::buffa::impl_view_reborrow!(DelegationView); +/** Self-contained, `'static` owned view of a `Delegation` message. + + Wraps [`::buffa::OwnedView`]`<`[`DelegationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DelegationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DelegationOwnedView(::buffa::OwnedView>); +impl DelegationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::Delegation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DelegationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DelegationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DelegationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::Delegation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 2: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Set for DELEGATION_KIND_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + #[must_use] + pub fn child_session_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().child_session_id + } + /// Field 4: `cascade_policy` + #[must_use] + pub fn cascade_policy( + &self, + ) -> ::core::option::Option< + ::buffa::EnumValue, + > { + self.0.reborrow().cascade_policy + } + /// Set for DELEGATION_KIND_EXTERNAL. + /// + /// Field 5: `delegate_reference` + #[must_use] + pub fn delegate_reference(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().delegate_reference + } + /// Field 6: `dispatched_at` + #[must_use] + pub fn dispatched_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().dispatched_at + } + /// Set once the child is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + #[must_use] + pub fn detach_operation_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detach_operation_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DelegationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DelegationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DelegationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DelegationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::Delegation { + type View<'a> = DelegationView<'a>; + type ViewHandle = DelegationOwnedView; +} +impl ::serde::Serialize for DelegationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct ExecutionAttemptView<'a> { + /// Field 1: `execution_attempt_id` + pub execution_attempt_id: &'a str, + /// Field 2: `attempt_number` + pub attempt_number: u64, + /// The attempt published its ready attestation; until then it holds the + /// session but must not be treated as serving. + /// + /// Field 3: `ready` + pub ready: bool, + /// Checkpoint the attempt restored from, empty when it started from scratch. + /// + /// Field 4: `restored_checkpoint_id` + pub restored_checkpoint_id: ::core::option::Option<&'a str>, + /// Ordinal of the ExecutionAttemptStarted event itself: the head the attempt + /// selected, and the point its tail replay resumes from. + /// + /// Field 5: `started_at` + pub started_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ExecutionAttemptView<'a> { + /**Whether required field `execution_attempt_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_attempt_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `attempt_number` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_attempt_number(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `ready` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ready(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `started_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_started_at(&self) -> bool { + self.started_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ExecutionAttemptView<'a> { + type Owned = super::super::ExecutionAttempt; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.execution_attempt_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.attempt_number = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ready = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.restored_checkpoint_id = Some( + ::buffa::types::borrow_str(&mut cur)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.started_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.started_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ExecutionAttempt { + execution_attempt_id: self.execution_attempt_id.to_string(), + attempt_number: self.attempt_number, + ready: self.ready, + restored_checkpoint_id: self.restored_checkpoint_id.map(|s| s.to_string()), + started_at: match self.started_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ExecutionAttemptView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.attempt_number) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if let Some(ref v) = self.restored_checkpoint_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.execution_attempt_id, buf); + ::buffa::types::put_uint64_field(2u32, self.attempt_number, buf); + ::buffa::types::put_bool_field(3u32, self.ready, buf); + if let Some(ref v) = self.restored_checkpoint_id { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ExecutionAttemptView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("executionAttemptId", self.execution_attempt_id)?; + } + { + __map + .serialize_entry( + "attemptNumber", + &::buffa::json_helpers::ProtoJson(&self.attempt_number), + )?; + } + { + __map.serialize_entry("ready", &self.ready)?; + } + if let ::core::option::Option::Some(__v) = self.restored_checkpoint_id { + __map.serialize_entry("restoredCheckpointId", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.started_at.as_option() { + __map.serialize_entry("startedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ExecutionAttemptView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ExecutionAttempt"; +} +::buffa::impl_default_view_instance!(ExecutionAttemptView); +::buffa::impl_view_reborrow!(ExecutionAttemptView); +/** Self-contained, `'static` owned view of a `ExecutionAttempt` message. + + Wraps [`::buffa::OwnedView`]`<`[`ExecutionAttemptView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ExecutionAttemptView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ExecutionAttemptOwnedView(::buffa::OwnedView>); +impl ExecutionAttemptOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExecutionAttemptOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExecutionAttemptOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ExecutionAttempt, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ExecutionAttemptOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ExecutionAttemptView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ExecutionAttemptView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ExecutionAttempt { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `execution_attempt_id` + #[must_use] + pub fn execution_attempt_id(&self) -> &'_ str { + self.0.reborrow().execution_attempt_id + } + /// Field 2: `attempt_number` + #[must_use] + pub fn attempt_number(&self) -> u64 { + self.0.reborrow().attempt_number + } + /// The attempt published its ready attestation; until then it holds the + /// session but must not be treated as serving. + /// + /// Field 3: `ready` + #[must_use] + pub fn ready(&self) -> bool { + self.0.reborrow().ready + } + /// Checkpoint the attempt restored from, empty when it started from scratch. + /// + /// Field 4: `restored_checkpoint_id` + #[must_use] + pub fn restored_checkpoint_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().restored_checkpoint_id + } + /// Ordinal of the ExecutionAttemptStarted event itself: the head the attempt + /// selected, and the point its tail replay resumes from. + /// + /// Field 5: `started_at` + #[must_use] + pub fn started_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().started_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ExecutionAttemptOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ExecutionAttemptOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ExecutionAttemptOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ExecutionAttemptOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ExecutionAttempt { + type View<'a> = ExecutionAttemptView<'a>; + type ViewHandle = ExecutionAttemptOwnedView; +} +impl ::serde::Serialize for ExecutionAttemptOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct CompactionMarkerView<'a> { + /// Field 1: `summary_id` + pub summary_id: &'a str, + /// Ordinal of the Compacted event itself. + /// + /// Field 2: `marker_ordinal` + pub marker_ordinal: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 3: `covers_from` + pub covers_from: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 4: `covers_through` + pub covers_through: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 5: `covered_input_digest` + pub covered_input_digest: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CompactionMarkerView<'a> { + /**Whether required field `summary_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `marker_ordinal` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_marker_ordinal(&self) -> bool { + self.marker_ordinal.is_set() + } + /**Whether required field `covers_from` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_from(&self) -> bool { + self.covers_from.is_set() + } + /**Whether required field `covers_through` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_through(&self) -> bool { + self.covers_through.is_set() + } + /**Whether required field `covered_input_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covered_input_digest(&self) -> bool { + self.covered_input_digest.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CompactionMarkerView<'a> { + type Owned = super::super::CompactionMarker; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.summary_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.marker_ordinal.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.marker_ordinal = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covers_from.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covers_from = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covers_through.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covers_through = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covered_input_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covered_input_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CompactionMarker { + summary_id: self.summary_id.to_string(), + marker_ordinal: match self.marker_ordinal.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + covers_from: match self.covers_from.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + covers_through: match self.covers_through.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + covered_input_digest: match self.covered_input_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CompactionMarkerView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_id) as u64; + if self.marker_ordinal.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.marker_ordinal.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covered_input_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covered_input_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.summary_id, buf); + if self.marker_ordinal.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.marker_ordinal.write_to(__cache, buf); + } + if self.covers_from.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_from.write_to(__cache, buf); + } + if self.covers_through.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_through.write_to(__cache, buf); + } + if self.covered_input_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covered_input_digest.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CompactionMarkerView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("summaryId", self.summary_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.marker_ordinal.as_option() { + __map.serialize_entry("markerOrdinal", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.covers_from.as_option() { + __map.serialize_entry("coversFrom", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.covers_through.as_option() { + __map.serialize_entry("coversThrough", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .covered_input_digest + .as_option() + { + __map.serialize_entry("coveredInputDigest", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CompactionMarkerView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "CompactionMarker"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.CompactionMarker"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CompactionMarker"; +} +::buffa::impl_default_view_instance!(CompactionMarkerView); +::buffa::impl_view_reborrow!(CompactionMarkerView); +/** Self-contained, `'static` owned view of a `CompactionMarker` message. + + Wraps [`::buffa::OwnedView`]`<`[`CompactionMarkerView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CompactionMarkerView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CompactionMarkerOwnedView(::buffa::OwnedView>); +impl CompactionMarkerOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionMarkerOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionMarkerOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CompactionMarker, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactionMarkerOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CompactionMarkerView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CompactionMarkerView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CompactionMarker { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `summary_id` + #[must_use] + pub fn summary_id(&self) -> &'_ str { + self.0.reborrow().summary_id + } + /// Ordinal of the Compacted event itself. + /// + /// Field 2: `marker_ordinal` + #[must_use] + pub fn marker_ordinal( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().marker_ordinal + } + /// Field 3: `covers_from` + #[must_use] + pub fn covers_from( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().covers_from + } + /// Field 4: `covers_through` + #[must_use] + pub fn covers_through( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().covers_through + } + /// Field 5: `covered_input_digest` + #[must_use] + pub fn covered_input_digest( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'_>, + > { + &self.0.reborrow().covered_input_digest + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CompactionMarkerOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CompactionMarkerOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CompactionMarkerOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CompactionMarkerOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CompactionMarker { + type View<'a> = CompactionMarkerView<'a>; + type ViewHandle = CompactionMarkerOwnedView; +} +impl ::serde::Serialize for CompactionMarkerOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct ToolCallView<'a> { + /// Field 1: `tool_call_id` + pub tool_call_id: &'a str, + /// Retry identity of the call, and the key its terminal outcome joins on. + /// + /// Field 2: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 3: `tool_name` + pub tool_name: &'a str, + /// Field 4: `turn_id` + pub turn_id: &'a str, + /// The operation ledger entry guarding this call's side effect, when it + /// reserves one. + /// + /// Field 5: `operation_id` + pub operation_id: ::core::option::Option<&'a str>, + /// Field 6: `status` + pub status: ::buffa::EnumValue, + /// Field 7: `requested_at` + pub requested_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Set when the call started executing. A call with started_at set and + /// settled_at unset is exactly an interrupted call awaiting reconciliation. + /// + /// Field 8: `started_at` + pub started_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Set by the first terminal outcome; a later conflicting one is audit-only. + /// + /// Field 9: `settled_at` + pub settled_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ToolCallView<'a> { + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_name` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_name(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `status` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_status(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `requested_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_requested_at(&self) -> bool { + self.requested_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ToolCallView<'a> { + type Owned = super::super::ToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_name = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.requested_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.requested_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.started_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.started_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.settled_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.settled_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ToolCall { + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + tool_name: self.tool_name.to_string(), + turn_id: self.turn_id.to_string(), + operation_id: self.operation_id.map(|s| s.to_string()), + status: self.status, + requested_at: match self.requested_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + started_at: match self.started_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + settled_at: match self.settled_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if let Some(ref v) = self.operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.requested_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.requested_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.settled_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settled_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_name, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + if let Some(ref v) = self.operation_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + ::buffa::types::put_int32_field(6u32, self.status.to_i32(), buf); + if self.requested_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.requested_at.write_to(__cache, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + if self.settled_at.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settled_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("toolName", self.tool_name)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + if let ::core::option::Option::Some(__v) = self.operation_id { + __map.serialize_entry("operationId", __v)?; + } + { + __map.serialize_entry("status", &self.status)?; + } + { + if let ::core::option::Option::Some(__v) = self.requested_at.as_option() { + __map.serialize_entry("requestedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.started_at.as_option() { + __map.serialize_entry("startedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.settled_at.as_option() { + __map.serialize_entry("settledAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ToolCall"; +} +::buffa::impl_default_view_instance!(ToolCallView); +::buffa::impl_view_reborrow!(ToolCallView); +/** Self-contained, `'static` owned view of a `ToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`ToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ToolCallOwnedView(::buffa::OwnedView>); +impl ToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(ToolCallOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ToolCallOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Retry identity of the call, and the key its terminal outcome joins on. + /// + /// Field 2: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 3: `tool_name` + #[must_use] + pub fn tool_name(&self) -> &'_ str { + self.0.reborrow().tool_name + } + /// Field 4: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// The operation ledger entry guarding this call's side effect, when it + /// reserves one. + /// + /// Field 5: `operation_id` + #[must_use] + pub fn operation_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().operation_id + } + /// Field 6: `status` + #[must_use] + pub fn status(&self) -> ::buffa::EnumValue { + self.0.reborrow().status + } + /// Field 7: `requested_at` + #[must_use] + pub fn requested_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().requested_at + } + /// Set when the call started executing. A call with started_at set and + /// settled_at unset is exactly an interrupted call awaiting reconciliation. + /// + /// Field 8: `started_at` + #[must_use] + pub fn started_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().started_at + } + /// Set by the first terminal outcome; a later conflicting one is audit-only. + /// + /// Field 9: `settled_at` + #[must_use] + pub fn settled_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().settled_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ToolCall { + type View<'a> = ToolCallView<'a>; + type ViewHandle = ToolCallOwnedView; +} +impl ::serde::Serialize for ToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct OperationView<'a> { + /// Field 1: `operation_id` + pub operation_id: &'a str, + /// Field 2: `operation_kind` + pub operation_kind: ::buffa::EnumValue< + super::super::super::super::v1alpha1::OperationKind, + >, + /// Digest of the reserved request, so a retry carrying different bytes under + /// the same id is refused instead of executed twice. + /// + /// Field 3: `request_digest` + pub request_digest: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'a>, + >, + /// Field 4: `status` + pub status: ::buffa::EnumValue, + /// Cancellation was asked for; it does not settle the operation, which still + /// needs a recorded outcome. + /// + /// Field 5: `cancellation_requested` + pub cancellation_requested: bool, + /// Field 6: `reserved_at` + pub reserved_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + /// Set by the determinate outcome that settled the operation. + /// + /// Field 7: `settled_at` + pub settled_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> OperationView<'a> { + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `request_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_request_digest(&self) -> bool { + self.request_digest.is_set() + } + /**Whether required field `status` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_status(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `cancellation_requested` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_cancellation_requested(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `reserved_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reserved_at(&self) -> bool { + self.reserved_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for OperationView<'a> { + type Owned = super::super::Operation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.operation_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.request_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.request_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cancellation_requested = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.reserved_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.reserved_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.settled_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.settled_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::Operation { + operation_id: self.operation_id.to_string(), + operation_kind: self.operation_kind, + request_digest: match self.request_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + status: self.status, + cancellation_requested: self.cancellation_requested, + reserved_at: match self.reserved_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + settled_at: match self.settled_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for OperationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.operation_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.reserved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.reserved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.settled_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settled_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.operation_kind.to_i32(), buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(4u32, self.status.to_i32(), buf); + ::buffa::types::put_bool_field(5u32, self.cancellation_requested, buf); + if self.reserved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.reserved_at.write_to(__cache, buf); + } + if self.settled_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settled_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for OperationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("operationKind", &self.operation_kind)?; + } + { + if let ::core::option::Option::Some(__v) = self.request_digest.as_option() { + __map.serialize_entry("requestDigest", __v)?; + } + } + { + __map.serialize_entry("status", &self.status)?; + } + { + __map + .serialize_entry("cancellationRequested", &self.cancellation_requested)?; + } + { + if let ::core::option::Option::Some(__v) = self.reserved_at.as_option() { + __map.serialize_entry("reservedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.settled_at.as_option() { + __map.serialize_entry("settledAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for OperationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "Operation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.Operation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Operation"; +} +::buffa::impl_default_view_instance!(OperationView); +::buffa::impl_view_reborrow!(OperationView); +/** Self-contained, `'static` owned view of a `Operation` message. + + Wraps [`::buffa::OwnedView`]`<`[`OperationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OperationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct OperationOwnedView(::buffa::OwnedView>); +impl OperationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::Operation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + OperationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`OperationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &OperationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::Operation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 2: `operation_kind` + #[must_use] + pub fn operation_kind( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().operation_kind + } + /// Digest of the reserved request, so a retry carrying different bytes under + /// the same id is refused instead of executed twice. + /// + /// Field 3: `request_digest` + #[must_use] + pub fn request_digest( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::DigestView<'_>, + > { + &self.0.reborrow().request_digest + } + /// Field 4: `status` + #[must_use] + pub fn status(&self) -> ::buffa::EnumValue { + self.0.reborrow().status + } + /// Cancellation was asked for; it does not settle the operation, which still + /// needs a recorded outcome. + /// + /// Field 5: `cancellation_requested` + #[must_use] + pub fn cancellation_requested(&self) -> bool { + self.0.reborrow().cancellation_requested + } + /// Field 6: `reserved_at` + #[must_use] + pub fn reserved_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().reserved_at + } + /// Set by the determinate outcome that settled the operation. + /// + /// Field 7: `settled_at` + #[must_use] + pub fn settled_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().settled_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for OperationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + OperationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: OperationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for OperationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::Operation { + type View<'a> = OperationView<'a>; + type ViewHandle = OperationOwnedView; +} +impl ::serde::Serialize for OperationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +#[derive(Clone, Debug, Default)] +pub struct CheckpointEvidenceView<'a> { + /// Field 1: `checkpoint_id` + pub checkpoint_id: &'a str, + /// Field 2: `checkpoint` + pub checkpoint: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::CheckpointView<'a>, + >, + /// Ordinal of the CheckpointProduced event that admitted this evidence. + /// + /// Field 3: `produced_at` + pub produced_at: ::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CheckpointEvidenceView<'a> { + /**Whether required field `checkpoint_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_checkpoint_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `checkpoint` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_checkpoint(&self) -> bool { + self.checkpoint.is_set() + } + /**Whether required field `produced_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_produced_at(&self) -> bool { + self.produced_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CheckpointEvidenceView<'a> { + type Owned = super::super::CheckpointEvidence; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.checkpoint_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.checkpoint.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.checkpoint = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.produced_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.produced_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CheckpointEvidence { + checkpoint_id: self.checkpoint_id.to_string(), + checkpoint: match self.checkpoint.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::Checkpoint, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + produced_at: match self.produced_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline< + super::super::super::super::v1alpha1::SessionOrdinal, + >, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CheckpointEvidenceView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.checkpoint_id) as u64; + if self.checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.produced_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.produced_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.checkpoint_id, buf); + if self.checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.checkpoint.write_to(__cache, buf); + } + if self.produced_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.produced_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CheckpointEvidenceView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("checkpointId", self.checkpoint_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.checkpoint.as_option() { + __map.serialize_entry("checkpoint", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.produced_at.as_option() { + __map.serialize_entry("producedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CheckpointEvidenceView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "CheckpointEvidence"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.CheckpointEvidence"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CheckpointEvidence"; +} +::buffa::impl_default_view_instance!(CheckpointEvidenceView); +::buffa::impl_view_reborrow!(CheckpointEvidenceView); +/** Self-contained, `'static` owned view of a `CheckpointEvidence` message. + + Wraps [`::buffa::OwnedView`]`<`[`CheckpointEvidenceView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CheckpointEvidenceView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CheckpointEvidenceOwnedView( + ::buffa::OwnedView>, +); +impl CheckpointEvidenceOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckpointEvidenceOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckpointEvidenceOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CheckpointEvidence, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CheckpointEvidenceOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CheckpointEvidenceView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CheckpointEvidenceView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CheckpointEvidence { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `checkpoint_id` + #[must_use] + pub fn checkpoint_id(&self) -> &'_ str { + self.0.reborrow().checkpoint_id + } + /// Field 2: `checkpoint` + #[must_use] + pub fn checkpoint( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::CheckpointView<'_>, + > { + &self.0.reborrow().checkpoint + } + /// Ordinal of the CheckpointProduced event that admitted this evidence. + /// + /// Field 3: `produced_at` + #[must_use] + pub fn produced_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::super::super::v1alpha1::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().produced_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CheckpointEvidenceOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CheckpointEvidenceOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CheckpointEvidenceOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CheckpointEvidenceOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CheckpointEvidence { + type View<'a> = CheckpointEvidenceView<'a>; + type ViewHandle = CheckpointEvidenceOwnedView; +} +impl ::serde::Serialize for CheckpointEvidenceOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.rs new file mode 100644 index 0000000000..00efc1c638 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.state.v1alpha1.state.rs @@ -0,0 +1,3878 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/state/v1alpha1/state.proto + +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum StateValue { + STATE_VALUE_UNSPECIFIED = 0i32, + /// No SessionStarted folded: the stream does not exist yet. + STATE_VALUE_MISSING = 1i32, + STATE_VALUE_ACTIVE = 2i32, + /// Sealed by a terminal marker: no further invariant-bearing transition is + /// admitted, though guarded ledger and lineage facts still fold so an + /// in-flight side effect stays reconcilable. + STATE_VALUE_TERMINAL = 3i32, +} +impl StateValue { + ///Idiomatic alias for [`Self::STATE_VALUE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::STATE_VALUE_UNSPECIFIED; + ///Idiomatic alias for [`Self::STATE_VALUE_MISSING`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Missing: Self = Self::STATE_VALUE_MISSING; + ///Idiomatic alias for [`Self::STATE_VALUE_ACTIVE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Active: Self = Self::STATE_VALUE_ACTIVE; + ///Idiomatic alias for [`Self::STATE_VALUE_TERMINAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Terminal: Self = Self::STATE_VALUE_TERMINAL; +} +impl ::core::default::Default for StateValue { + fn default() -> Self { + Self::STATE_VALUE_UNSPECIFIED + } +} +impl ::serde::Serialize for StateValue { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for StateValue { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = StateValue; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(StateValue)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for StateValue { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for StateValue { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::STATE_VALUE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::STATE_VALUE_MISSING), + 2i32 => ::core::option::Option::Some(Self::STATE_VALUE_ACTIVE), + 3i32 => ::core::option::Option::Some(Self::STATE_VALUE_TERMINAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::STATE_VALUE_UNSPECIFIED => "STATE_VALUE_UNSPECIFIED", + Self::STATE_VALUE_MISSING => "STATE_VALUE_MISSING", + Self::STATE_VALUE_ACTIVE => "STATE_VALUE_ACTIVE", + Self::STATE_VALUE_TERMINAL => "STATE_VALUE_TERMINAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "STATE_VALUE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::STATE_VALUE_UNSPECIFIED) + } + "STATE_VALUE_MISSING" => { + ::core::option::Option::Some(Self::STATE_VALUE_MISSING) + } + "STATE_VALUE_ACTIVE" => { + ::core::option::Option::Some(Self::STATE_VALUE_ACTIVE) + } + "STATE_VALUE_TERMINAL" => { + ::core::option::Option::Some(Self::STATE_VALUE_TERMINAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::STATE_VALUE_UNSPECIFIED, + Self::STATE_VALUE_MISSING, + Self::STATE_VALUE_ACTIVE, + Self::STATE_VALUE_TERMINAL, + ] + } +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TerminalMarker { + TERMINAL_MARKER_UNSPECIFIED = 0i32, + TERMINAL_MARKER_CLOSED = 1i32, + TERMINAL_MARKER_CANCELLED = 2i32, + TERMINAL_MARKER_FAILED = 3i32, + TERMINAL_MARKER_HIDDEN = 4i32, +} +impl TerminalMarker { + ///Idiomatic alias for [`Self::TERMINAL_MARKER_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TERMINAL_MARKER_UNSPECIFIED; + ///Idiomatic alias for [`Self::TERMINAL_MARKER_CLOSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Closed: Self = Self::TERMINAL_MARKER_CLOSED; + ///Idiomatic alias for [`Self::TERMINAL_MARKER_CANCELLED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Cancelled: Self = Self::TERMINAL_MARKER_CANCELLED; + ///Idiomatic alias for [`Self::TERMINAL_MARKER_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::TERMINAL_MARKER_FAILED; + ///Idiomatic alias for [`Self::TERMINAL_MARKER_HIDDEN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Hidden: Self = Self::TERMINAL_MARKER_HIDDEN; +} +impl ::core::default::Default for TerminalMarker { + fn default() -> Self { + Self::TERMINAL_MARKER_UNSPECIFIED + } +} +impl ::serde::Serialize for TerminalMarker { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TerminalMarker { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TerminalMarker; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TerminalMarker) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TerminalMarker { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TerminalMarker { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TERMINAL_MARKER_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TERMINAL_MARKER_CLOSED), + 2i32 => ::core::option::Option::Some(Self::TERMINAL_MARKER_CANCELLED), + 3i32 => ::core::option::Option::Some(Self::TERMINAL_MARKER_FAILED), + 4i32 => ::core::option::Option::Some(Self::TERMINAL_MARKER_HIDDEN), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TERMINAL_MARKER_UNSPECIFIED => "TERMINAL_MARKER_UNSPECIFIED", + Self::TERMINAL_MARKER_CLOSED => "TERMINAL_MARKER_CLOSED", + Self::TERMINAL_MARKER_CANCELLED => "TERMINAL_MARKER_CANCELLED", + Self::TERMINAL_MARKER_FAILED => "TERMINAL_MARKER_FAILED", + Self::TERMINAL_MARKER_HIDDEN => "TERMINAL_MARKER_HIDDEN", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TERMINAL_MARKER_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TERMINAL_MARKER_UNSPECIFIED) + } + "TERMINAL_MARKER_CLOSED" => { + ::core::option::Option::Some(Self::TERMINAL_MARKER_CLOSED) + } + "TERMINAL_MARKER_CANCELLED" => { + ::core::option::Option::Some(Self::TERMINAL_MARKER_CANCELLED) + } + "TERMINAL_MARKER_FAILED" => { + ::core::option::Option::Some(Self::TERMINAL_MARKER_FAILED) + } + "TERMINAL_MARKER_HIDDEN" => { + ::core::option::Option::Some(Self::TERMINAL_MARKER_HIDDEN) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TERMINAL_MARKER_UNSPECIFIED, + Self::TERMINAL_MARKER_CLOSED, + Self::TERMINAL_MARKER_CANCELLED, + Self::TERMINAL_MARKER_FAILED, + Self::TERMINAL_MARKER_HIDDEN, + ] + } +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum DelegationKind { + DELEGATION_KIND_UNSPECIFIED = 0i32, + DELEGATION_KIND_CHILD_SESSION = 1i32, + DELEGATION_KIND_EXTERNAL = 2i32, +} +impl DelegationKind { + ///Idiomatic alias for [`Self::DELEGATION_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::DELEGATION_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::DELEGATION_KIND_CHILD_SESSION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChildSession: Self = Self::DELEGATION_KIND_CHILD_SESSION; + ///Idiomatic alias for [`Self::DELEGATION_KIND_EXTERNAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const External: Self = Self::DELEGATION_KIND_EXTERNAL; +} +impl ::core::default::Default for DelegationKind { + fn default() -> Self { + Self::DELEGATION_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for DelegationKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for DelegationKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = DelegationKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(DelegationKind) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for DelegationKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for DelegationKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::DELEGATION_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::DELEGATION_KIND_CHILD_SESSION), + 2i32 => ::core::option::Option::Some(Self::DELEGATION_KIND_EXTERNAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::DELEGATION_KIND_UNSPECIFIED => "DELEGATION_KIND_UNSPECIFIED", + Self::DELEGATION_KIND_CHILD_SESSION => "DELEGATION_KIND_CHILD_SESSION", + Self::DELEGATION_KIND_EXTERNAL => "DELEGATION_KIND_EXTERNAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "DELEGATION_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_UNSPECIFIED) + } + "DELEGATION_KIND_CHILD_SESSION" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_CHILD_SESSION) + } + "DELEGATION_KIND_EXTERNAL" => { + ::core::option::Option::Some(Self::DELEGATION_KIND_EXTERNAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::DELEGATION_KIND_UNSPECIFIED, + Self::DELEGATION_KIND_CHILD_SESSION, + Self::DELEGATION_KIND_EXTERNAL, + ] + } +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ToolCallStatus { + TOOL_CALL_STATUS_UNSPECIFIED = 0i32, + TOOL_CALL_STATUS_REQUESTED = 1i32, + TOOL_CALL_STATUS_APPROVED = 2i32, + /// Terminal: the call was refused and never ran. + TOOL_CALL_STATUS_DENIED = 3i32, + TOOL_CALL_STATUS_STARTED = 4i32, + TOOL_CALL_STATUS_COMPLETED = 5i32, + TOOL_CALL_STATUS_FAILED = 6i32, +} +impl ToolCallStatus { + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TOOL_CALL_STATUS_UNSPECIFIED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_REQUESTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Requested: Self = Self::TOOL_CALL_STATUS_REQUESTED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_APPROVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Approved: Self = Self::TOOL_CALL_STATUS_APPROVED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Denied: Self = Self::TOOL_CALL_STATUS_DENIED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_STARTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Started: Self = Self::TOOL_CALL_STATUS_STARTED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_COMPLETED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Completed: Self = Self::TOOL_CALL_STATUS_COMPLETED; + ///Idiomatic alias for [`Self::TOOL_CALL_STATUS_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::TOOL_CALL_STATUS_FAILED; +} +impl ::core::default::Default for ToolCallStatus { + fn default() -> Self { + Self::TOOL_CALL_STATUS_UNSPECIFIED + } +} +impl ::serde::Serialize for ToolCallStatus { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ToolCallStatus { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ToolCallStatus; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ToolCallStatus) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ToolCallStatus { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ToolCallStatus { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_REQUESTED), + 2i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_APPROVED), + 3i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_DENIED), + 4i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_STARTED), + 5i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_COMPLETED), + 6i32 => ::core::option::Option::Some(Self::TOOL_CALL_STATUS_FAILED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TOOL_CALL_STATUS_UNSPECIFIED => "TOOL_CALL_STATUS_UNSPECIFIED", + Self::TOOL_CALL_STATUS_REQUESTED => "TOOL_CALL_STATUS_REQUESTED", + Self::TOOL_CALL_STATUS_APPROVED => "TOOL_CALL_STATUS_APPROVED", + Self::TOOL_CALL_STATUS_DENIED => "TOOL_CALL_STATUS_DENIED", + Self::TOOL_CALL_STATUS_STARTED => "TOOL_CALL_STATUS_STARTED", + Self::TOOL_CALL_STATUS_COMPLETED => "TOOL_CALL_STATUS_COMPLETED", + Self::TOOL_CALL_STATUS_FAILED => "TOOL_CALL_STATUS_FAILED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TOOL_CALL_STATUS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_UNSPECIFIED) + } + "TOOL_CALL_STATUS_REQUESTED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_REQUESTED) + } + "TOOL_CALL_STATUS_APPROVED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_APPROVED) + } + "TOOL_CALL_STATUS_DENIED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_DENIED) + } + "TOOL_CALL_STATUS_STARTED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_STARTED) + } + "TOOL_CALL_STATUS_COMPLETED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_COMPLETED) + } + "TOOL_CALL_STATUS_FAILED" => { + ::core::option::Option::Some(Self::TOOL_CALL_STATUS_FAILED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TOOL_CALL_STATUS_UNSPECIFIED, + Self::TOOL_CALL_STATUS_REQUESTED, + Self::TOOL_CALL_STATUS_APPROVED, + Self::TOOL_CALL_STATUS_DENIED, + Self::TOOL_CALL_STATUS_STARTED, + Self::TOOL_CALL_STATUS_COMPLETED, + Self::TOOL_CALL_STATUS_FAILED, + ] + } +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum OperationStatus { + OPERATION_STATUS_UNSPECIFIED = 0i32, + /// Reserved, no outcome recorded: the side effect may or may not have run. + OPERATION_STATUS_RESERVED = 1i32, + /// Recorded as indeterminate. Non-terminal, and supersedable exactly once by + /// a determinate outcome. + OPERATION_STATUS_UNKNOWN = 2i32, + OPERATION_STATUS_SUCCEEDED = 3i32, + OPERATION_STATUS_FAILED = 4i32, + OPERATION_STATUS_CANCELLED = 5i32, +} +impl OperationStatus { + ///Idiomatic alias for [`Self::OPERATION_STATUS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::OPERATION_STATUS_UNSPECIFIED; + ///Idiomatic alias for [`Self::OPERATION_STATUS_RESERVED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Reserved: Self = Self::OPERATION_STATUS_RESERVED; + ///Idiomatic alias for [`Self::OPERATION_STATUS_UNKNOWN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unknown: Self = Self::OPERATION_STATUS_UNKNOWN; + ///Idiomatic alias for [`Self::OPERATION_STATUS_SUCCEEDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Succeeded: Self = Self::OPERATION_STATUS_SUCCEEDED; + ///Idiomatic alias for [`Self::OPERATION_STATUS_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Failed: Self = Self::OPERATION_STATUS_FAILED; + ///Idiomatic alias for [`Self::OPERATION_STATUS_CANCELLED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Cancelled: Self = Self::OPERATION_STATUS_CANCELLED; +} +impl ::core::default::Default for OperationStatus { + fn default() -> Self { + Self::OPERATION_STATUS_UNSPECIFIED + } +} +impl ::serde::Serialize for OperationStatus { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for OperationStatus { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = OperationStatus; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(OperationStatus) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for OperationStatus { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for OperationStatus { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_RESERVED), + 2i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_UNKNOWN), + 3i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_SUCCEEDED), + 4i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_FAILED), + 5i32 => ::core::option::Option::Some(Self::OPERATION_STATUS_CANCELLED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::OPERATION_STATUS_UNSPECIFIED => "OPERATION_STATUS_UNSPECIFIED", + Self::OPERATION_STATUS_RESERVED => "OPERATION_STATUS_RESERVED", + Self::OPERATION_STATUS_UNKNOWN => "OPERATION_STATUS_UNKNOWN", + Self::OPERATION_STATUS_SUCCEEDED => "OPERATION_STATUS_SUCCEEDED", + Self::OPERATION_STATUS_FAILED => "OPERATION_STATUS_FAILED", + Self::OPERATION_STATUS_CANCELLED => "OPERATION_STATUS_CANCELLED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "OPERATION_STATUS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_UNSPECIFIED) + } + "OPERATION_STATUS_RESERVED" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_RESERVED) + } + "OPERATION_STATUS_UNKNOWN" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_UNKNOWN) + } + "OPERATION_STATUS_SUCCEEDED" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_SUCCEEDED) + } + "OPERATION_STATUS_FAILED" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_FAILED) + } + "OPERATION_STATUS_CANCELLED" => { + ::core::option::Option::Some(Self::OPERATION_STATUS_CANCELLED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::OPERATION_STATUS_UNSPECIFIED, + Self::OPERATION_STATUS_RESERVED, + Self::OPERATION_STATUS_UNKNOWN, + Self::OPERATION_STATUS_SUCCEEDED, + Self::OPERATION_STATUS_FAILED, + Self::OPERATION_STATUS_CANCELLED, + ] + } +} +/// State is the Session aggregate's write-side fold: exactly the facts the +/// session commands read to enforce their invariants, and nothing a read model +/// owns (ADR#0035, ADR#0045). It is never a projection and never a transcript; +/// message bodies, todo items, artifacts, and display metadata are deliberately +/// absent because no command reads them. +/// +/// A crash between a started tool call and its outcome is the load-bearing case: +/// replaying a session leaves that call in TOOL_CALL_STATUS_STARTED with no +/// settled_at, and its reserved operation in OPERATION_STATUS_RESERVED, so +/// reconciliation can see the missing terminal outcome and finish or reject the +/// interrupted call rather than silently dropping it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct State { + /// Field 1: `state` + #[serde(rename = "state", with = "::buffa::json_helpers::proto_enum")] + pub state: ::buffa::EnumValue, + /// Field 2: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Count of events folded so far: this session's own fold-derived ordinal of + /// the last applied event, never a JetStream sequence (ADR#0013). + /// + /// Field 3: `position` + #[serde(rename = "position")] + pub position: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Digest of the immutable StoredSessionExecutionPlan recorded at start; every + /// attempt, checkpoint, and compaction is bound to it. + /// + /// Field 4: `execution_plan_digest` + #[serde( + rename = "executionPlanDigest", + alias = "execution_plan_digest", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub execution_plan_digest: ::buffa::MessageField< + super::super::v1alpha1::Digest, + ::buffa::Inline, + >, + /// Which marker sealed the session. The first terminal marker wins; a later one + /// is audit-only. + /// + /// Field 5: `terminal_marker` + #[serde( + rename = "terminalMarker", + alias = "terminal_marker", + with = "::buffa::json_helpers::proto_enum" + )] + pub terminal_marker: ::buffa::EnumValue, + /// Context root when this session was forked from another one; unset for a + /// session that started its own context. + /// + /// Field 6: `fork_origin` + #[serde( + rename = "forkOrigin", + alias = "fork_origin", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub fork_origin: ::buffa::MessageField>, + /// Provenance of a salvaged session; unset for a session that was not + /// recovered from a damaged source. Folded because it is a precondition the + /// commands must be able to read: a session that is a partial copy cannot + /// honor a rewind or a compaction against source positions it never received. + /// + /// Field 19: `recovery_origin` + #[serde( + rename = "recoveryOrigin", + alias = "recovery_origin", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub recovery_origin: ::buffa::MessageField< + RecoveryOrigin, + ::buffa::Inline, + >, + /// Recorded parent lineage of a delegated child session. + /// + /// Field 7: `parent` + #[serde( + rename = "parent", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub parent: ::buffa::MessageField>, + /// Newest rewind boundary. Rewind masks effective history for readers and + /// future turns; it never un-applies folded facts, because a tool call that + /// really ran still has to be reconcilable. + /// + /// Field 8: `keep_through` + #[serde( + rename = "keepThrough", + alias = "keep_through", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub keep_through: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Newest compaction marker, the prior usable boundary a further compaction + /// and an attempt restore both resolve against. + /// + /// Field 9: `compaction` + #[serde( + rename = "compaction", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub compaction: ::buffa::MessageField< + CompactionMarker, + ::buffa::Inline, + >, + /// Attempt currently holding the session; unset when no attempt is running. + /// + /// Field 10: `active_attempt` + #[serde( + rename = "activeAttempt", + alias = "active_attempt", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub active_attempt: ::buffa::MessageField< + ExecutionAttempt, + ::buffa::Inline, + >, + /// Most recently started attempt, still active or already ended, so a new + /// attempt can be checked for monotonic numbering and exact predecessor. + /// + /// Field 11: `last_attempt_id` + #[serde( + rename = "lastAttemptId", + alias = "last_attempt_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub last_attempt_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 12: `last_attempt_number` + #[serde( + rename = "lastAttemptNumber", + alias = "last_attempt_number", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub last_attempt_number: ::core::option::Option, + /// Tool calls keyed by tool_call_id, in first-observed fold order. + /// + /// Field 13: `tool_calls` + #[serde( + rename = "toolCalls", + alias = "tool_calls", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub tool_calls: ::buffa::alloc::vec::Vec, + /// Operation ledger entries keyed by operation_id, in reservation fold order. + /// + /// Field 14: `operations` + #[serde( + rename = "operations", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub operations: ::buffa::alloc::vec::Vec, + /// Dispatched delegations keyed by operation_id, parent side. + /// + /// Field 15: `delegations` + #[serde( + rename = "delegations", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub delegations: ::buffa::alloc::vec::Vec, + /// First admitted evidence per checkpoint_id; a later event reusing an id is + /// retained on the log but never replaces the admitted evidence. + /// + /// Field 16: `checkpoints` + #[serde( + rename = "checkpoints", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub checkpoints: ::buffa::alloc::vec::Vec, + /// Privacy dependencies an attempt restore and a compaction must respect. + /// + /// Field 17: `redacted_event_ids` + #[serde( + rename = "redactedEventIds", + alias = "redacted_event_ids", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub redacted_event_ids: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 18: `erased_artifact_ids` + #[serde( + rename = "erasedArtifactIds", + alias = "erased_artifact_ids", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub erased_artifact_ids: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for State { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("State") + .field("state", &self.state) + .field("session_id", &self.session_id) + .field("position", &self.position) + .field("execution_plan_digest", &self.execution_plan_digest) + .field("terminal_marker", &self.terminal_marker) + .field("fork_origin", &self.fork_origin) + .field("recovery_origin", &self.recovery_origin) + .field("parent", &self.parent) + .field("keep_through", &self.keep_through) + .field("compaction", &self.compaction) + .field("active_attempt", &self.active_attempt) + .field("last_attempt_id", &self.last_attempt_id) + .field("last_attempt_number", &self.last_attempt_number) + .field("tool_calls", &self.tool_calls) + .field("operations", &self.operations) + .field("delegations", &self.delegations) + .field("checkpoints", &self.checkpoints) + .field("redacted_event_ids", &self.redacted_event_ids) + .field("erased_artifact_ids", &self.erased_artifact_ids) + .finish() + } +} +impl State { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.State"; +} +impl State { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::last_attempt_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_last_attempt_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.last_attempt_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::last_attempt_number`] to `Some(value)`, consuming and returning `self`. + pub fn with_last_attempt_number(mut self, value: u64) -> Self { + self.last_attempt_number = Some(value); + self + } +} +::buffa::impl_default_instance!(State); +impl ::buffa::MessageName for State { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "State"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.State"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.State"; +} +impl ::buffa::Message for State { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.position.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.position.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.execution_plan_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.terminal_marker.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.fork_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fork_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.parent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.compaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.compaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.active_attempt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.active_attempt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.last_attempt_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.last_attempt_number { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + for v in &self.tool_calls { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.operations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.delegations { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.checkpoints { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 2u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.redacted_event_ids { + size += 2u64 + ::buffa::types::string_encoded_len(v) as u64; + } + for v in &self.erased_artifact_ids { + size += 2u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.recovery_origin.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.recovery_origin.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 2u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.state.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.session_id, buf); + if self.position.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.position.write_to(__cache, buf); + } + if self.execution_plan_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(5u32, self.terminal_marker.to_i32(), buf); + if self.fork_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.fork_origin.write_to(__cache, buf); + } + if self.parent.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent.write_to(__cache, buf); + } + if self.keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.keep_through.write_to(__cache, buf); + } + if self.compaction.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.compaction.write_to(__cache, buf); + } + if self.active_attempt.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.active_attempt.write_to(__cache, buf); + } + if let Some(ref v) = self.last_attempt_id { + ::buffa::types::put_string_field(11u32, v, buf); + } + if let Some(v) = self.last_attempt_number { + ::buffa::types::put_uint64_field(12u32, v, buf); + } + for v in &self.tool_calls { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.operations { + ::buffa::types::put_len_delimited_header( + 14u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.delegations { + ::buffa::types::put_len_delimited_header( + 15u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.checkpoints { + ::buffa::types::put_len_delimited_header( + 16u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.redacted_event_ids { + ::buffa::types::put_string_field(17u32, v, buf); + } + for v in &self.erased_artifact_ids { + ::buffa::types::put_string_field(18u32, v, buf); + } + if self.recovery_origin.is_set() { + ::buffa::types::put_len_delimited_header( + 19u32, + u64::from(__cache.consume_next()), + buf, + ); + self.recovery_origin.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.position.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.execution_plan_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.terminal_marker = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.fork_origin.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.parent.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.keep_through.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.compaction.get_or_insert_default(), + buf, + ctx, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.active_attempt.get_or_insert_default(), + buf, + ctx, + )?; + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .last_attempt_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.last_attempt_number = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.tool_calls.push(elem); + } + 14u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.operations.push(elem); + } + 15u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.delegations.push(elem); + } + 16u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.checkpoints.push(elem); + } + 17u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + self.redacted_event_ids.push(__elem); + } + 18u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + self.erased_artifact_ids.push(__elem); + } + 19u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.recovery_origin.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.state = ::buffa::EnumValue::from(0); + self.session_id.clear(); + self.position = ::buffa::MessageField::none(); + self.execution_plan_digest = ::buffa::MessageField::none(); + self.terminal_marker = ::buffa::EnumValue::from(0); + self.fork_origin = ::buffa::MessageField::none(); + self.parent = ::buffa::MessageField::none(); + self.keep_through = ::buffa::MessageField::none(); + self.compaction = ::buffa::MessageField::none(); + self.active_attempt = ::buffa::MessageField::none(); + self.last_attempt_id = ::core::option::Option::None; + self.last_attempt_number = ::core::option::Option::None; + self.tool_calls.clear(); + self.operations.clear(); + self.delegations.clear(); + self.checkpoints.clear(); + self.redacted_event_ids.clear(); + self.erased_artifact_ids.clear(); + self.recovery_origin = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for State { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STATE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.State", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ForkOrigin { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// Field 2: `context_prefix_boundary` + #[serde(rename = "contextPrefixBoundary", alias = "context_prefix_boundary")] + pub context_prefix_boundary: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ForkOrigin { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ForkOrigin") + .field("source_session_id", &self.source_session_id) + .field("context_prefix_boundary", &self.context_prefix_boundary) + .finish() + } +} +impl ForkOrigin { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ForkOrigin"; +} +::buffa::impl_default_instance!(ForkOrigin); +impl ::buffa::MessageName for ForkOrigin { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ForkOrigin"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ForkOrigin"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ForkOrigin"; +} +impl ::buffa::Message for ForkOrigin { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.context_prefix_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_prefix_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + if self.context_prefix_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_prefix_boundary.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.context_prefix_boundary.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.context_prefix_boundary = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ForkOrigin { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FORK_ORIGIN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ForkOrigin", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// RecoveryOrigin is the damaged source a salvaged session was copied from. +/// +/// source_boundary is a position on the source's stream, not on this one. This +/// session's ordinals count its own events and start at 1 regardless of where the +/// source's cut ended. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecoveryOrigin { + /// Field 1: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// Field 2: `source_boundary` + #[serde(rename = "sourceBoundary", alias = "source_boundary")] + pub source_boundary: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Field 3: `source_digest` + #[serde(rename = "sourceDigest", alias = "source_digest")] + pub source_digest: ::buffa::MessageField< + super::super::v1alpha1::Digest, + ::buffa::Inline, + >, + /// Field 4: `salvage_key` + #[serde( + rename = "salvageKey", + alias = "salvage_key", + with = "::buffa::json_helpers::proto_string" + )] + pub salvage_key: ::buffa::alloc::string::String, + /// Field 5: `completeness` + #[serde(rename = "completeness", with = "::buffa::json_helpers::proto_enum")] + pub completeness: ::buffa::EnumValue, + /// Field 6: `omitted_count` + #[serde( + rename = "omittedCount", + alias = "omitted_count", + with = "::buffa::json_helpers::uint32" + )] + pub omitted_count: u32, +} +impl ::core::fmt::Debug for RecoveryOrigin { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecoveryOrigin") + .field("source_session_id", &self.source_session_id) + .field("source_boundary", &self.source_boundary) + .field("source_digest", &self.source_digest) + .field("salvage_key", &self.salvage_key) + .field("completeness", &self.completeness) + .field("omitted_count", &self.omitted_count) + .finish() + } +} +impl RecoveryOrigin { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.RecoveryOrigin"; +} +::buffa::impl_default_instance!(RecoveryOrigin); +impl ::buffa::MessageName for RecoveryOrigin { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "RecoveryOrigin"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.RecoveryOrigin"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.RecoveryOrigin"; +} +impl ::buffa::Message for RecoveryOrigin { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(5u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(6u32, self.omitted_count, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_boundary.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.salvage_key, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.omitted_count = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.source_session_id.clear(); + self.source_boundary = ::buffa::MessageField::none(); + self.source_digest = ::buffa::MessageField::none(); + self.salvage_key.clear(); + self.completeness = ::buffa::EnumValue::from(0); + self.omitted_count = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecoveryOrigin { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECOVERY_ORIGIN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.RecoveryOrigin", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ParentLink { + /// Field 1: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// The parent's own ordinal of the dispatch that created this session. + /// + /// Field 2: `parent_dispatched_at` + #[serde(rename = "parentDispatchedAt", alias = "parent_dispatched_at")] + pub parent_dispatched_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Field 3: `cascade_policy` + #[serde( + rename = "cascadePolicy", + alias = "cascade_policy", + with = "::buffa::json_helpers::proto_enum" + )] + pub cascade_policy: ::buffa::EnumValue, + /// The parent-side operation this session was dispatched under. + /// + /// Field 4: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// The parent reached a terminal state and this session observed it. + /// + /// Field 5: `parent_terminated` + #[serde( + rename = "parentTerminated", + alias = "parent_terminated", + with = "::buffa::json_helpers::proto_bool" + )] + pub parent_terminated: bool, + /// The parent rewound past the dispatch: the inherited prefix no longer holds. + /// + /// Field 6: `history_invalidated` + #[serde( + rename = "historyInvalidated", + alias = "history_invalidated", + with = "::buffa::json_helpers::proto_bool" + )] + pub history_invalidated: bool, + /// Set once the lineage is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + #[serde( + rename = "detachOperationId", + alias = "detach_operation_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub detach_operation_id: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for ParentLink { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ParentLink") + .field("parent_session_id", &self.parent_session_id) + .field("parent_dispatched_at", &self.parent_dispatched_at) + .field("cascade_policy", &self.cascade_policy) + .field("operation_id", &self.operation_id) + .field("parent_terminated", &self.parent_terminated) + .field("history_invalidated", &self.history_invalidated) + .field("detach_operation_id", &self.detach_operation_id) + .finish() + } +} +impl ParentLink { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ParentLink"; +} +impl ParentLink { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detach_operation_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_detach_operation_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detach_operation_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ParentLink); +impl ::buffa::MessageName for ParentLink { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ParentLink"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ParentLink"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ParentLink"; +} +impl ::buffa::Message for ParentLink { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if let Some(ref v) = self.detach_operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.parent_session_id, buf); + if self.parent_dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_dispatched_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.cascade_policy.to_i32(), buf); + ::buffa::types::put_string_field(4u32, &self.operation_id, buf); + ::buffa::types::put_bool_field(5u32, self.parent_terminated, buf); + ::buffa::types::put_bool_field(6u32, self.history_invalidated, buf); + if let Some(ref v) = self.detach_operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.parent_dispatched_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.parent_terminated = ::buffa::types::decode_bool(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.history_invalidated = ::buffa::types::decode_bool(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .detach_operation_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.parent_session_id.clear(); + self.parent_dispatched_at = ::buffa::MessageField::none(); + self.cascade_policy = ::buffa::EnumValue::from(0); + self.operation_id.clear(); + self.parent_terminated = false; + self.history_invalidated = false; + self.detach_operation_id = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ParentLink { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PARENT_LINK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ParentLink", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Delegation { + /// Field 1: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 2: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Set for DELEGATION_KIND_CHILD_SESSION. + /// + /// Field 3: `child_session_id` + #[serde( + rename = "childSessionId", + alias = "child_session_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub child_session_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 4: `cascade_policy` + #[serde( + rename = "cascadePolicy", + alias = "cascade_policy", + with = "::buffa::json_helpers::opt_enum", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub cascade_policy: ::core::option::Option< + ::buffa::EnumValue, + >, + /// Set for DELEGATION_KIND_EXTERNAL. + /// + /// Field 5: `delegate_reference` + #[serde( + rename = "delegateReference", + alias = "delegate_reference", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub delegate_reference: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 6: `dispatched_at` + #[serde(rename = "dispatchedAt", alias = "dispatched_at")] + pub dispatched_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Set once the child is detached, making the detach idempotent per id. + /// + /// Field 7: `detach_operation_id` + #[serde( + rename = "detachOperationId", + alias = "detach_operation_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub detach_operation_id: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for Delegation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Delegation") + .field("operation_id", &self.operation_id) + .field("kind", &self.kind) + .field("child_session_id", &self.child_session_id) + .field("cascade_policy", &self.cascade_policy) + .field("delegate_reference", &self.delegate_reference) + .field("dispatched_at", &self.dispatched_at) + .field("detach_operation_id", &self.detach_operation_id) + .finish() + } +} +impl Delegation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Delegation"; +} +impl Delegation { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::child_session_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_child_session_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.child_session_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::cascade_policy`] to `Some(value)`, consuming and returning `self`. + pub fn with_cascade_policy( + mut self, + value: impl Into<::buffa::EnumValue>, + ) -> Self { + self.cascade_policy = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::delegate_reference`] to `Some(value)`, consuming and returning `self`. + pub fn with_delegate_reference( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.delegate_reference = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detach_operation_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_detach_operation_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detach_operation_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(Delegation); +impl ::buffa::MessageName for Delegation { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "Delegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.Delegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Delegation"; +} +impl ::buffa::Message for Delegation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.child_session_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.cascade_policy { + size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64; + } + if let Some(ref v) = self.delegate_reference { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detach_operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if let Some(ref v) = self.child_session_id { + ::buffa::types::put_string_field(3u32, v, buf); + } + if let Some(ref v) = self.cascade_policy { + ::buffa::types::put_int32_field(4u32, v.to_i32(), buf); + } + if let Some(ref v) = self.delegate_reference { + ::buffa::types::put_string_field(5u32, v, buf); + } + if self.dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.dispatched_at.write_to(__cache, buf); + } + if let Some(ref v) = self.detach_operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .child_session_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cascade_policy = ::core::option::Option::Some( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .delegate_reference + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.dispatched_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .detach_operation_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.operation_id.clear(); + self.kind = ::buffa::EnumValue::from(0); + self.child_session_id = ::core::option::Option::None; + self.cascade_policy = ::core::option::Option::None; + self.delegate_reference = ::core::option::Option::None; + self.dispatched_at = ::buffa::MessageField::none(); + self.detach_operation_id = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for Delegation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DELEGATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Delegation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ExecutionAttempt { + /// Field 1: `execution_attempt_id` + #[serde( + rename = "executionAttemptId", + alias = "execution_attempt_id", + with = "::buffa::json_helpers::proto_string" + )] + pub execution_attempt_id: ::buffa::alloc::string::String, + /// Field 2: `attempt_number` + #[serde( + rename = "attemptNumber", + alias = "attempt_number", + with = "::buffa::json_helpers::uint64" + )] + pub attempt_number: u64, + /// The attempt published its ready attestation; until then it holds the + /// session but must not be treated as serving. + /// + /// Field 3: `ready` + #[serde(rename = "ready", with = "::buffa::json_helpers::proto_bool")] + pub ready: bool, + /// Checkpoint the attempt restored from, empty when it started from scratch. + /// + /// Field 4: `restored_checkpoint_id` + #[serde( + rename = "restoredCheckpointId", + alias = "restored_checkpoint_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub restored_checkpoint_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Ordinal of the ExecutionAttemptStarted event itself: the head the attempt + /// selected, and the point its tail replay resumes from. + /// + /// Field 5: `started_at` + #[serde(rename = "startedAt", alias = "started_at")] + pub started_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ExecutionAttempt { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ExecutionAttempt") + .field("execution_attempt_id", &self.execution_attempt_id) + .field("attempt_number", &self.attempt_number) + .field("ready", &self.ready) + .field("restored_checkpoint_id", &self.restored_checkpoint_id) + .field("started_at", &self.started_at) + .finish() + } +} +impl ExecutionAttempt { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ExecutionAttempt"; +} +impl ExecutionAttempt { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::restored_checkpoint_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_restored_checkpoint_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.restored_checkpoint_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ExecutionAttempt); +impl ::buffa::MessageName for ExecutionAttempt { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ExecutionAttempt"; +} +impl ::buffa::Message for ExecutionAttempt { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.attempt_number) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if let Some(ref v) = self.restored_checkpoint_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.execution_attempt_id, buf); + ::buffa::types::put_uint64_field(2u32, self.attempt_number, buf); + ::buffa::types::put_bool_field(3u32, self.ready, buf); + if let Some(ref v) = self.restored_checkpoint_id { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.execution_attempt_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.attempt_number = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ready = ::buffa::types::decode_bool(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .restored_checkpoint_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.started_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.execution_attempt_id.clear(); + self.attempt_number = 0u64; + self.ready = false; + self.restored_checkpoint_id = ::core::option::Option::None; + self.started_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ExecutionAttempt { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __EXECUTION_ATTEMPT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ExecutionAttempt", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CompactionMarker { + /// Field 1: `summary_id` + #[serde( + rename = "summaryId", + alias = "summary_id", + with = "::buffa::json_helpers::proto_string" + )] + pub summary_id: ::buffa::alloc::string::String, + /// Ordinal of the Compacted event itself. + /// + /// Field 2: `marker_ordinal` + #[serde(rename = "markerOrdinal", alias = "marker_ordinal")] + pub marker_ordinal: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Field 3: `covers_from` + #[serde(rename = "coversFrom", alias = "covers_from")] + pub covers_from: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Field 4: `covers_through` + #[serde(rename = "coversThrough", alias = "covers_through")] + pub covers_through: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Field 5: `covered_input_digest` + #[serde(rename = "coveredInputDigest", alias = "covered_input_digest")] + pub covered_input_digest: ::buffa::MessageField< + super::super::v1alpha1::Digest, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for CompactionMarker { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CompactionMarker") + .field("summary_id", &self.summary_id) + .field("marker_ordinal", &self.marker_ordinal) + .field("covers_from", &self.covers_from) + .field("covers_through", &self.covers_through) + .field("covered_input_digest", &self.covered_input_digest) + .finish() + } +} +impl CompactionMarker { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CompactionMarker"; +} +::buffa::impl_default_instance!(CompactionMarker); +impl ::buffa::MessageName for CompactionMarker { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "CompactionMarker"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.CompactionMarker"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CompactionMarker"; +} +impl ::buffa::Message for CompactionMarker { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_id) as u64; + if self.marker_ordinal.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.marker_ordinal.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covered_input_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covered_input_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.summary_id, buf); + if self.marker_ordinal.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.marker_ordinal.write_to(__cache, buf); + } + if self.covers_from.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_from.write_to(__cache, buf); + } + if self.covers_through.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_through.write_to(__cache, buf); + } + if self.covered_input_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covered_input_digest.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.summary_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.marker_ordinal.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covers_from.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covers_through.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covered_input_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.summary_id.clear(); + self.marker_ordinal = ::buffa::MessageField::none(); + self.covers_from = ::buffa::MessageField::none(); + self.covers_through = ::buffa::MessageField::none(); + self.covered_input_digest = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CompactionMarker { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMPACTION_MARKER_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CompactionMarker", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ToolCall { + /// Field 1: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Retry identity of the call, and the key its terminal outcome joins on. + /// + /// Field 2: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 3: `tool_name` + #[serde( + rename = "toolName", + alias = "tool_name", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_name: ::buffa::alloc::string::String, + /// Field 4: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// The operation ledger entry guarding this call's side effect, when it + /// reserves one. + /// + /// Field 5: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub operation_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 6: `status` + #[serde(rename = "status", with = "::buffa::json_helpers::proto_enum")] + pub status: ::buffa::EnumValue, + /// Field 7: `requested_at` + #[serde(rename = "requestedAt", alias = "requested_at")] + pub requested_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Set when the call started executing. A call with started_at set and + /// settled_at unset is exactly an interrupted call awaiting reconciliation. + /// + /// Field 8: `started_at` + #[serde( + rename = "startedAt", + alias = "started_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub started_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Set by the first terminal outcome; a later conflicting one is audit-only. + /// + /// Field 9: `settled_at` + #[serde( + rename = "settledAt", + alias = "settled_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub settled_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for ToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ToolCall") + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("tool_name", &self.tool_name) + .field("turn_id", &self.turn_id) + .field("operation_id", &self.operation_id) + .field("status", &self.status) + .field("requested_at", &self.requested_at) + .field("started_at", &self.started_at) + .field("settled_at", &self.settled_at) + .finish() + } +} +impl ToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ToolCall"; +} +impl ToolCall { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::operation_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_operation_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.operation_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ToolCall); +impl ::buffa::MessageName for ToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "ToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.ToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ToolCall"; +} +impl ::buffa::Message for ToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if let Some(ref v) = self.operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.requested_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.requested_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.settled_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settled_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_name, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + if let Some(ref v) = self.operation_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + ::buffa::types::put_int32_field(6u32, self.status.to_i32(), buf); + if self.requested_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.requested_at.write_to(__cache, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + if self.settled_at.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settled_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_name, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .operation_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.requested_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.started_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.settled_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.tool_name.clear(); + self.turn_id.clear(); + self.operation_id = ::core::option::Option::None; + self.status = ::buffa::EnumValue::from(0); + self.requested_at = ::buffa::MessageField::none(); + self.started_at = ::buffa::MessageField::none(); + self.settled_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.ToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Operation { + /// Field 1: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 2: `operation_kind` + #[serde( + rename = "operationKind", + alias = "operation_kind", + with = "::buffa::json_helpers::proto_enum" + )] + pub operation_kind: ::buffa::EnumValue, + /// Digest of the reserved request, so a retry carrying different bytes under + /// the same id is refused instead of executed twice. + /// + /// Field 3: `request_digest` + #[serde(rename = "requestDigest", alias = "request_digest")] + pub request_digest: ::buffa::MessageField< + super::super::v1alpha1::Digest, + ::buffa::Inline, + >, + /// Field 4: `status` + #[serde(rename = "status", with = "::buffa::json_helpers::proto_enum")] + pub status: ::buffa::EnumValue, + /// Cancellation was asked for; it does not settle the operation, which still + /// needs a recorded outcome. + /// + /// Field 5: `cancellation_requested` + #[serde( + rename = "cancellationRequested", + alias = "cancellation_requested", + with = "::buffa::json_helpers::proto_bool" + )] + pub cancellation_requested: bool, + /// Field 6: `reserved_at` + #[serde(rename = "reservedAt", alias = "reserved_at")] + pub reserved_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, + /// Set by the determinate outcome that settled the operation. + /// + /// Field 7: `settled_at` + #[serde( + rename = "settledAt", + alias = "settled_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub settled_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for Operation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Operation") + .field("operation_id", &self.operation_id) + .field("operation_kind", &self.operation_kind) + .field("request_digest", &self.request_digest) + .field("status", &self.status) + .field("cancellation_requested", &self.cancellation_requested) + .field("reserved_at", &self.reserved_at) + .field("settled_at", &self.settled_at) + .finish() + } +} +impl Operation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Operation"; +} +::buffa::impl_default_instance!(Operation); +impl ::buffa::MessageName for Operation { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "Operation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.Operation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Operation"; +} +impl ::buffa::Message for Operation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + { + let val = self.operation_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.status.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.reserved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.reserved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.settled_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settled_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + ::buffa::types::put_int32_field(2u32, self.operation_kind.to_i32(), buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(4u32, self.status.to_i32(), buf); + ::buffa::types::put_bool_field(5u32, self.cancellation_requested, buf); + if self.reserved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.reserved_at.write_to(__cache, buf); + } + if self.settled_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settled_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.operation_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.request_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.status = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cancellation_requested = ::buffa::types::decode_bool(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.reserved_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.settled_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.operation_id.clear(); + self.operation_kind = ::buffa::EnumValue::from(0); + self.request_digest = ::buffa::MessageField::none(); + self.status = ::buffa::EnumValue::from(0); + self.cancellation_requested = false; + self.reserved_at = ::buffa::MessageField::none(); + self.settled_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Operation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OPERATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.Operation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CheckpointEvidence { + /// Field 1: `checkpoint_id` + #[serde( + rename = "checkpointId", + alias = "checkpoint_id", + with = "::buffa::json_helpers::proto_string" + )] + pub checkpoint_id: ::buffa::alloc::string::String, + /// Field 2: `checkpoint` + #[serde(rename = "checkpoint")] + pub checkpoint: ::buffa::MessageField< + super::super::v1alpha1::Checkpoint, + ::buffa::Inline, + >, + /// Ordinal of the CheckpointProduced event that admitted this evidence. + /// + /// Field 3: `produced_at` + #[serde(rename = "producedAt", alias = "produced_at")] + pub produced_at: ::buffa::MessageField< + super::super::v1alpha1::SessionOrdinal, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for CheckpointEvidence { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CheckpointEvidence") + .field("checkpoint_id", &self.checkpoint_id) + .field("checkpoint", &self.checkpoint) + .field("produced_at", &self.produced_at) + .finish() + } +} +impl CheckpointEvidence { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CheckpointEvidence"; +} +::buffa::impl_default_instance!(CheckpointEvidence); +impl ::buffa::MessageName for CheckpointEvidence { + const PACKAGE: &'static str = "trogonai.session.sessions.state.v1alpha1"; + const NAME: &'static str = "CheckpointEvidence"; + const FULL_NAME: &'static str = "trogonai.session.sessions.state.v1alpha1.CheckpointEvidence"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CheckpointEvidence"; +} +impl ::buffa::Message for CheckpointEvidence { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.checkpoint_id) as u64; + if self.checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.produced_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.produced_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.checkpoint_id, buf); + if self.checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.checkpoint.write_to(__cache, buf); + } + if self.produced_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.produced_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.checkpoint_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.checkpoint.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.produced_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.checkpoint_id.clear(); + self.checkpoint = ::buffa::MessageField::none(); + self.produced_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CheckpointEvidence { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CHECKPOINT_EVIDENCE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.state.v1alpha1.CheckpointEvidence", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.__view.rs new file mode 100644 index 0000000000..d0e7ba9db9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.__view.rs @@ -0,0 +1,315 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/apply_redaction.proto + +/// ApplyRedaction marks recorded events as redacted, recording +/// \[RedactionApplied\]. Redaction is a recorded fact about history, not a +/// rewrite of it (ADR#0035 facet 5). +/// +/// Write precondition At. The invariant that the targeted ids exist in this +/// session cannot be checked from folded state today: no event carries its own +/// envelope id into evolve, which ADR#0035 lists as an unmet substrate +/// obligation. +#[derive(Clone, Debug, Default)] +pub struct ApplyRedactionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `redacted_event_ids` + pub redacted_event_ids: ::buffa::RepeatedView<'a, &'a str>, + /// Field 3: `reason` + pub reason: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ApplyRedactionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ApplyRedactionView<'a> { + type Owned = super::super::ApplyRedaction; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::borrow_str(&mut cur)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + view.redacted_event_ids.push(__elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ApplyRedaction { + session_id: self.session_id.to_string(), + redacted_event_ids: self + .redacted_event_ids + .iter() + .map(|s| s.to_string()) + .collect(), + reason: self.reason.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ApplyRedactionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + for v in &self.redacted_event_ids { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + for v in &self.redacted_event_ids { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ApplyRedactionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + if !self.redacted_event_ids.is_empty() { + __map.serialize_entry("redactedEventIds", &*self.redacted_event_ids)?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ApplyRedactionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ApplyRedaction"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ApplyRedaction"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApplyRedaction"; +} +::buffa::impl_default_view_instance!(ApplyRedactionView); +::buffa::impl_view_reborrow!(ApplyRedactionView); +/** Self-contained, `'static` owned view of a `ApplyRedaction` message. + + Wraps [`::buffa::OwnedView`]`<`[`ApplyRedactionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ApplyRedactionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ApplyRedactionOwnedView(::buffa::OwnedView>); +impl ApplyRedactionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApplyRedactionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApplyRedactionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ApplyRedaction, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApplyRedactionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ApplyRedactionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ApplyRedactionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ApplyRedaction { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `redacted_event_ids` + #[must_use] + pub fn redacted_event_ids(&self) -> &::buffa::RepeatedView<'_, &'_ str> { + &self.0.reborrow().redacted_event_ids + } + /// Field 3: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ApplyRedactionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ApplyRedactionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ApplyRedactionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ApplyRedactionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ApplyRedaction { + type View<'a> = ApplyRedactionView<'a>; + type ViewHandle = ApplyRedactionOwnedView; +} +impl ::serde::Serialize for ApplyRedactionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.rs new file mode 100644 index 0000000000..36d597d702 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.apply_redaction.rs @@ -0,0 +1,177 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/apply_redaction.proto + +/// ApplyRedaction marks recorded events as redacted, recording +/// \[RedactionApplied\]. Redaction is a recorded fact about history, not a +/// rewrite of it (ADR#0035 facet 5). +/// +/// Write precondition At. The invariant that the targeted ids exist in this +/// session cannot be checked from folded state today: no event carries its own +/// envelope id into evolve, which ADR#0035 lists as an unmet substrate +/// obligation. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ApplyRedaction { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `redacted_event_ids` + #[serde( + rename = "redactedEventIds", + alias = "redacted_event_ids", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub redacted_event_ids: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Field 3: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for ApplyRedaction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ApplyRedaction") + .field("session_id", &self.session_id) + .field("redacted_event_ids", &self.redacted_event_ids) + .field("reason", &self.reason) + .finish() + } +} +impl ApplyRedaction { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApplyRedaction"; +} +impl ApplyRedaction { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ApplyRedaction); +impl ::buffa::MessageName for ApplyRedaction { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ApplyRedaction"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ApplyRedaction"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApplyRedaction"; +} +impl ::buffa::Message for ApplyRedaction { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + for v in &self.redacted_event_ids { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + for v in &self.redacted_event_ids { + ::buffa::types::put_string_field(2u32, v, buf); + } + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __elem = ::buffa::types::decode_string(buf)?; + ctx.register_element_memory( + ::buffa::__private::element_footprint(&__elem), + )?; + self.redacted_event_ids.push(__elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.redacted_event_ids.clear(); + self.reason = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ApplyRedaction { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __APPLY_REDACTION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApplyRedaction", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.__view.rs new file mode 100644 index 0000000000..978d8ce0b7 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.__view.rs @@ -0,0 +1,369 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/approve_tool_call.proto + +/// ApproveToolCall records a human decision to allow a call, recording +/// \[ToolCallApproved\]. +/// +/// Write precondition At: approve and deny are mutually exclusive, so a decision +/// taken against a stale head must be rejected rather than appended beside its +/// opposite. +#[derive(Clone, Debug, Default)] +pub struct ApproveToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `approved_by` + pub approved_by: &'a str, + /// Field 5: `turn_id` + pub turn_id: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ApproveToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `approved_by` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_approved_by(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ApproveToolCallView<'a> { + type Owned = super::super::ApproveToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.approved_by = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ApproveToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + approved_by: self.approved_by.to_string(), + turn_id: self.turn_id.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ApproveToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.approved_by) as u64; + if let Some(ref v) = self.turn_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.approved_by, buf); + if let Some(ref v) = self.turn_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ApproveToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("approvedBy", self.approved_by)?; + } + if let ::core::option::Option::Some(__v) = self.turn_id { + __map.serialize_entry("turnId", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ApproveToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ApproveToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ApproveToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApproveToolCall"; +} +::buffa::impl_default_view_instance!(ApproveToolCallView); +::buffa::impl_view_reborrow!(ApproveToolCallView); +/** Self-contained, `'static` owned view of a `ApproveToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`ApproveToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ApproveToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ApproveToolCallOwnedView(::buffa::OwnedView>); +impl ApproveToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApproveToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApproveToolCallOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ApproveToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ApproveToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ApproveToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ApproveToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ApproveToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `approved_by` + #[must_use] + pub fn approved_by(&self) -> &'_ str { + self.0.reborrow().approved_by + } + /// Field 5: `turn_id` + #[must_use] + pub fn turn_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ApproveToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ApproveToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ApproveToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ApproveToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ApproveToolCall { + type View<'a> = ApproveToolCallView<'a>; + type ViewHandle = ApproveToolCallOwnedView; +} +impl ::serde::Serialize for ApproveToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.rs new file mode 100644 index 0000000000..aabb679f1c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.approve_tool_call.rs @@ -0,0 +1,207 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/approve_tool_call.proto + +/// ApproveToolCall records a human decision to allow a call, recording +/// \[ToolCallApproved\]. +/// +/// Write precondition At: approve and deny are mutually exclusive, so a decision +/// taken against a stale head must be rejected rather than appended beside its +/// opposite. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ApproveToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `approved_by` + #[serde( + rename = "approvedBy", + alias = "approved_by", + with = "::buffa::json_helpers::proto_string" + )] + pub approved_by: ::buffa::alloc::string::String, + /// Field 5: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub turn_id: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for ApproveToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ApproveToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("approved_by", &self.approved_by) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl ApproveToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApproveToolCall"; +} +impl ApproveToolCall { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::turn_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_turn_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.turn_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ApproveToolCall); +impl ::buffa::MessageName for ApproveToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ApproveToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ApproveToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApproveToolCall"; +} +impl ::buffa::Message for ApproveToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.approved_by) as u64; + if let Some(ref v) = self.turn_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.approved_by, buf); + if let Some(ref v) = self.turn_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.approved_by, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.turn_id.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.approved_by.clear(); + self.turn_id = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ApproveToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __APPROVE_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ApproveToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.__view.rs new file mode 100644 index 0000000000..9abff0a27b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.__view.rs @@ -0,0 +1,256 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/archive_session.proto + +/// ArchiveSession moves a session out of the default listing view, recording +/// \[SessionArchived\]. Reversible organization state, unlike the terminal +/// HideSession. +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct ArchiveSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ArchiveSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ArchiveSessionView<'a> { + type Owned = super::super::ArchiveSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ArchiveSession { + session_id: self.session_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ArchiveSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ArchiveSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ArchiveSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ArchiveSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ArchiveSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ArchiveSession"; +} +::buffa::impl_default_view_instance!(ArchiveSessionView); +::buffa::impl_view_reborrow!(ArchiveSessionView); +/** Self-contained, `'static` owned view of a `ArchiveSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`ArchiveSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ArchiveSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ArchiveSessionOwnedView(::buffa::OwnedView>); +impl ArchiveSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArchiveSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArchiveSessionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ArchiveSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ArchiveSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ArchiveSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ArchiveSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ArchiveSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ArchiveSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ArchiveSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ArchiveSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ArchiveSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ArchiveSession { + type View<'a> = ArchiveSessionView<'a>; + type ViewHandle = ArchiveSessionOwnedView; +} +impl ::serde::Serialize for ArchiveSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.rs new file mode 100644 index 0000000000..095d914ecb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.archive_session.rs @@ -0,0 +1,112 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/archive_session.proto + +/// ArchiveSession moves a session out of the default listing view, recording +/// \[SessionArchived\]. Reversible organization state, unlike the terminal +/// HideSession. +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ArchiveSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for ArchiveSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ArchiveSession").field("session_id", &self.session_id).finish() + } +} +impl ArchiveSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ArchiveSession"; +} +::buffa::impl_default_instance!(ArchiveSession); +impl ::buffa::MessageName for ArchiveSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ArchiveSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ArchiveSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ArchiveSession"; +} +impl ::buffa::Message for ArchiveSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ArchiveSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ARCHIVE_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ArchiveSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.__view.rs index 179baf4754..9cc1099ab7 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.__view.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.__view.rs @@ -1077,6 +1077,14 @@ pub struct StoredArtifactView<'a> { /// /// Field 4: `mime` pub mime: &'a str, + /// Chunk hashing that lets a caller check part of this artifact without + /// reading all of it. Unset when the artifact was stored without one, which + /// means no range of it can be checked. + /// + /// Field 5: `chunks` + pub chunks: ::buffa::MessageFieldView< + super::super::__buffa::view::ContentChunksView<'a>, + >, #[doc(hidden)] pub __buffa_required_seen_0: u64, } @@ -1187,6 +1195,27 @@ impl<'a> ::buffa::MessageView<'a> for StoredArtifactView<'a> { view.mime = ::buffa::types::borrow_str(&mut cur)?; view.__buffa_required_seen_0 |= 4u64; } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.chunks.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.chunks = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } _ => { ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; } @@ -1219,6 +1248,15 @@ impl<'a> ::buffa::MessageView<'a> for StoredArtifactView<'a> { size_bytes: self.size_bytes, storage_ref: self.storage_ref.to_string(), mime: self.mime.to_string(), + chunks: match self.chunks.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ContentChunks, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, ..::core::default::Default::default() }) } @@ -1240,6 +1278,14 @@ impl<'a> ::buffa::ViewEncode<'a> for StoredArtifactView<'a> { size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; size += 1u64 + ::buffa::types::string_encoded_len(&self.storage_ref) as u64; size += 1u64 + ::buffa::types::string_encoded_len(&self.mime) as u64; + if self.chunks.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.chunks.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } ::buffa::saturate_size(size) } #[allow(clippy::needless_borrow)] @@ -1261,6 +1307,14 @@ impl<'a> ::buffa::ViewEncode<'a> for StoredArtifactView<'a> { ::buffa::types::put_uint64_field(2u32, self.size_bytes, buf); ::buffa::types::put_string_field(3u32, &self.storage_ref, buf); ::buffa::types::put_string_field(4u32, &self.mime, buf); + if self.chunks.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.chunks.write_to(__cache, buf); + } } } /// Serializes this view as protobuf JSON. @@ -1299,6 +1353,11 @@ impl<'__a> ::serde::Serialize for StoredArtifactView<'__a> { { __map.serialize_entry("mime", self.mime)?; } + { + if let ::core::option::Option::Some(__v) = self.chunks.as_option() { + __map.serialize_entry("chunks", __v)?; + } + } __map.end() } } @@ -1422,6 +1481,17 @@ impl StoredArtifactOwnedView { pub fn mime(&self) -> &'_ str { self.0.reborrow().mime } + /// Chunk hashing that lets a caller check part of this artifact without + /// reading all of it. Unset when the artifact was stored without one, which + /// means no range of it can be checked. + /// + /// Field 5: `chunks` + #[must_use] + pub fn chunks( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().chunks + } } impl ::core::convert::From<::buffa::OwnedView>> for StoredArtifactOwnedView { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.rs index 662ce064d1..45df0188e0 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.artifact.rs @@ -789,6 +789,16 @@ pub struct StoredArtifact { /// Field 4: `mime` #[serde(rename = "mime", with = "::buffa::json_helpers::proto_string")] pub mime: ::buffa::alloc::string::String, + /// Chunk hashing that lets a caller check part of this artifact without + /// reading all of it. Unset when the artifact was stored without one, which + /// means no range of it can be checked. + /// + /// Field 5: `chunks` + #[serde( + rename = "chunks", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub chunks: ::buffa::MessageField>, } impl ::core::fmt::Debug for StoredArtifact { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -797,6 +807,7 @@ impl ::core::fmt::Debug for StoredArtifact { .field("size_bytes", &self.size_bytes) .field("storage_ref", &self.storage_ref) .field("mime", &self.mime) + .field("chunks", &self.chunks) .finish() } } @@ -838,6 +849,14 @@ impl ::buffa::Message for StoredArtifact { size += 1u64 + ::buffa::types::uint64_encoded_len(self.size_bytes) as u64; size += 1u64 + ::buffa::types::string_encoded_len(&self.storage_ref) as u64; size += 1u64 + ::buffa::types::string_encoded_len(&self.mime) as u64; + if self.chunks.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.chunks.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } ::buffa::saturate_size(size) } fn write_to( @@ -858,6 +877,14 @@ impl ::buffa::Message for StoredArtifact { ::buffa::types::put_uint64_field(2u32, self.size_bytes, buf); ::buffa::types::put_string_field(3u32, &self.storage_ref, buf); ::buffa::types::put_string_field(4u32, &self.mime, buf); + if self.chunks.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.chunks.write_to(__cache, buf); + } } fn merge_field( &mut self, @@ -902,6 +929,17 @@ impl ::buffa::Message for StoredArtifact { )?; ::buffa::types::merge_string(&mut self.mime, buf)?; } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.chunks.get_or_insert_default(), + buf, + ctx, + )?; + } _ => { ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } @@ -913,6 +951,7 @@ impl ::buffa::Message for StoredArtifact { self.size_bytes = 0u64; self.storage_ref.clear(); self.mime.clear(); + self.chunks = ::buffa::MessageField::none(); } } impl ::buffa::json_helpers::ProtoElemJson for StoredArtifact { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.__view.rs new file mode 100644 index 0000000000..27abc7907c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.__view.rs @@ -0,0 +1,310 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/cancel_session.proto + +/// CancelSession seals a session as cancelled, recording \[SessionCancelled\]. +/// +/// Write precondition At: rejected if the session is already terminal. +#[derive(Clone, Debug, Default)] +pub struct CancelSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `reason` + pub reason: ::buffa::EnumValue, + /// Field 3: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CancelSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CancelSessionView<'a> { + type Owned = super::super::CancelSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CancelSession { + session_id: self.session_id.to_string(), + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CancelSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CancelSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CancelSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CancelSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CancelSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CancelSession"; +} +::buffa::impl_default_view_instance!(CancelSessionView); +::buffa::impl_view_reborrow!(CancelSessionView); +/** Self-contained, `'static` owned view of a `CancelSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`CancelSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CancelSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CancelSessionOwnedView(::buffa::OwnedView>); +impl CancelSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CancelSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CancelSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CancelSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CancelSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CancelSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CancelSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CancelSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 3: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CancelSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CancelSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CancelSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CancelSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CancelSession { + type View<'a> = CancelSessionView<'a>; + type ViewHandle = CancelSessionOwnedView; +} +impl ::serde::Serialize for CancelSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.rs new file mode 100644 index 0000000000..ece783c73e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.cancel_session.rs @@ -0,0 +1,164 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/cancel_session.proto + +/// CancelSession seals a session as cancelled, recording \[SessionCancelled\]. +/// +/// Write precondition At: rejected if the session is already terminal. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CancelSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 3: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for CancelSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CancelSession") + .field("session_id", &self.session_id) + .field("reason", &self.reason) + .field("detail", &self.detail) + .finish() + } +} +impl CancelSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CancelSession"; +} +impl CancelSession { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(CancelSession); +impl ::buffa::MessageName for CancelSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CancelSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CancelSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CancelSession"; +} +impl ::buffa::Message for CancelSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CancelSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CANCEL_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CancelSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.__view.rs new file mode 100644 index 0000000000..c9ebcb374e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.__view.rs @@ -0,0 +1,319 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/close_session.proto + +/// CloseSession seals a session as completed, recording \[SessionClosed\]. +/// +/// Write precondition At: the first terminal marker is authoritative, so a +/// decision taken against a stale head must be rejected rather than appended. +#[derive(Clone, Debug, Default)] +pub struct CloseSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Out-of-line result of the session's work, when it produced one. + /// + /// Field 2: `result_ref` + pub result_ref: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CloseSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CloseSessionView<'a> { + type Owned = super::super::CloseSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.result_ref.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.result_ref = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CloseSession { + session_id: self.session_id.to_string(), + result_ref: match self.result_ref.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CloseSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.result_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.result_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.result_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.result_ref.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CloseSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.result_ref.as_option() { + __map.serialize_entry("resultRef", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CloseSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CloseSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CloseSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CloseSession"; +} +::buffa::impl_default_view_instance!(CloseSessionView); +::buffa::impl_view_reborrow!(CloseSessionView); +/** Self-contained, `'static` owned view of a `CloseSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`CloseSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CloseSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CloseSessionOwnedView(::buffa::OwnedView>); +impl CloseSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CloseSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CloseSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CloseSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CloseSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CloseSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CloseSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CloseSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Out-of-line result of the session's work, when it produced one. + /// + /// Field 2: `result_ref` + #[must_use] + pub fn result_ref( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().result_ref + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CloseSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CloseSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CloseSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CloseSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CloseSession { + type View<'a> = CloseSessionView<'a>; + type ViewHandle = CloseSessionOwnedView; +} +impl ::serde::Serialize for CloseSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.rs new file mode 100644 index 0000000000..62b1e861bb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.close_session.rs @@ -0,0 +1,151 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/close_session.proto + +/// CloseSession seals a session as completed, recording \[SessionClosed\]. +/// +/// Write precondition At: the first terminal marker is authoritative, so a +/// decision taken against a stale head must be rejected rather than appended. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CloseSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Out-of-line result of the session's work, when it produced one. + /// + /// Field 2: `result_ref` + #[serde( + rename = "resultRef", + alias = "result_ref", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub result_ref: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for CloseSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CloseSession") + .field("session_id", &self.session_id) + .field("result_ref", &self.result_ref) + .finish() + } +} +impl CloseSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CloseSession"; +} +::buffa::impl_default_instance!(CloseSession); +impl ::buffa::MessageName for CloseSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CloseSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CloseSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CloseSession"; +} +impl ::buffa::Message for CloseSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.result_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.result_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.result_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.result_ref.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.result_ref.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.result_ref = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CloseSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CLOSE_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CloseSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.__view.rs new file mode 100644 index 0000000000..21825fccf1 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.__view.rs @@ -0,0 +1,1021 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/command_output_replay.proto + +/// CommandOutputReplayRef is a claim-check to the captured output of a +/// process-executing tool call, plus the small set of facts a reader needs +/// before it is allowed to render any of it. +/// +/// The output itself is an artifact: one immutable, content-addressed blob of +/// framed stdout and stderr, referenced from the terminal event rather than +/// appended to the log as an event per chunk. A long command emits millions of +/// writes, and a log that records them is a log whose size is set by the noisiest +/// thing that ever ran on it, permanently, because nothing ever leaves the log +/// (ADR#0035 facet 7). +/// +/// It lives on ToolCallCompleted, next to CommandTermination and for the same +/// reason (D11): it is the execution and audit record, not the transcript the +/// model received. The model saw ToolCallResult, which is usually a truncation +/// or a summary. Putting raw captured output into the replay shape would feed a +/// later turn context the original turn never had. +/// +/// Every field here is on the log rather than only inside the artifact, because +/// the artifact's bytes may be erased (ArtifactErased) while the log keeps its +/// provenance. After erasure a reader can still say the command produced 2.1 +/// million frames and 40 MB and was captured through a terminal, which is the +/// point of separating byte lifecycle from log retention. +#[derive(Clone, Debug, Default)] +pub struct CommandOutputReplayRefView<'a> { + /// Claim-check to the framed capture. Its `preview` conventionally holds the + /// tail of the output, which is the part someone reading a command log wants + /// first. + /// + /// Field 1: `artifact` + pub artifact: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + /// Version of the byte layout inside the artifact, as defined by + /// trogonai.session.sessions.replay.v1alpha1. + /// + /// Carried as a number and not read out of the artifact's media type, because + /// a reader deciding whether it can parse these frames should not be doing + /// string surgery on a MIME parameter to find out. + /// + /// Field 2: `format_version` + pub format_version: u32, + /// Field 3: `capture_mode` + pub capture_mode: ::buffa::EnumValue, + /// Field 4: `timing` + pub timing: ::buffa::EnumValue, + /// Field 5: `completeness` + pub completeness: ::buffa::MessageFieldView< + super::super::__buffa::view::ReplayCompletenessView<'a>, + >, + /// Frames in the capture. + /// + /// Field 6: `frame_count` + pub frame_count: u64, + /// Payload bytes across all frames, which is the size of the output as a user + /// understands it. Always smaller than ArtifactRef.size_bytes, which includes + /// framing overhead and the index. + /// + /// Field 7: `output_byte_count` + pub output_byte_count: u64, + /// Where the seek index sits inside the artifact. + /// + /// The index is a trailer, because a capturer streaming a running process does + /// not know it until the process exits and so cannot write it as a header. Its + /// location is recorded here so a reader can range-read the index directly, + /// rather than seeking relative to an end-of-object the artifact store might + /// report differently than the log does. + /// + /// Field 8: `index_offset` + pub index_offset: u64, + /// Field 9: `index_length` + pub index_length: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CommandOutputReplayRefView<'a> { + /**Whether required field `artifact` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact(&self) -> bool { + self.artifact.is_set() + } + /**Whether required field `format_version` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_format_version(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `capture_mode` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_capture_mode(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `timing` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_timing(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `completeness` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.completeness.is_set() + } + /**Whether required field `frame_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_frame_count(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `output_byte_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_output_byte_count(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `index_offset` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_index_offset(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } + /**Whether required field `index_length` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_index_length(&self) -> bool { + self.__buffa_required_seen_0 & 64u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CommandOutputReplayRefView<'a> { + type Owned = super::super::CommandOutputReplayRef; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.artifact.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.artifact = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.format_version = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.capture_mode = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.timing = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.completeness.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.completeness = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.frame_count = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.output_byte_count = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.index_offset = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.index_length = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 64u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::CommandOutputReplayRef, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::CommandOutputReplayRef, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CommandOutputReplayRef { + artifact: match self.artifact.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + format_version: self.format_version, + capture_mode: self.capture_mode, + timing: self.timing, + completeness: match self.completeness.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ReplayCompleteness, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + frame_count: self.frame_count, + output_byte_count: self.output_byte_count, + index_offset: self.index_offset, + index_length: self.index_length, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CommandOutputReplayRefView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.artifact.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifact.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + { + let val = self.capture_mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.timing.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.completeness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.completeness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.index_offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.index_length) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.artifact.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifact.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(2u32, self.format_version, buf); + ::buffa::types::put_int32_field(3u32, self.capture_mode.to_i32(), buf); + ::buffa::types::put_int32_field(4u32, self.timing.to_i32(), buf); + if self.completeness.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.completeness.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(6u32, self.frame_count, buf); + ::buffa::types::put_uint64_field(7u32, self.output_byte_count, buf); + ::buffa::types::put_uint64_field(8u32, self.index_offset, buf); + ::buffa::types::put_uint64_field(9u32, self.index_length, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CommandOutputReplayRefView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.artifact.as_option() { + __map.serialize_entry("artifact", __v)?; + } + } + { + __map + .serialize_entry( + "formatVersion", + &::buffa::json_helpers::ProtoJson(&self.format_version), + )?; + } + { + __map.serialize_entry("captureMode", &self.capture_mode)?; + } + { + __map.serialize_entry("timing", &self.timing)?; + } + { + if let ::core::option::Option::Some(__v) = self.completeness.as_option() { + __map.serialize_entry("completeness", __v)?; + } + } + { + __map + .serialize_entry( + "frameCount", + &::buffa::json_helpers::ProtoJson(&self.frame_count), + )?; + } + { + __map + .serialize_entry( + "outputByteCount", + &::buffa::json_helpers::ProtoJson(&self.output_byte_count), + )?; + } + { + __map + .serialize_entry( + "indexOffset", + &::buffa::json_helpers::ProtoJson(&self.index_offset), + )?; + } + { + __map + .serialize_entry( + "indexLength", + &::buffa::json_helpers::ProtoJson(&self.index_length), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CommandOutputReplayRefView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CommandOutputReplayRef"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CommandOutputReplayRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CommandOutputReplayRef"; +} +::buffa::impl_default_view_instance!(CommandOutputReplayRefView); +::buffa::impl_view_reborrow!(CommandOutputReplayRefView); +/** Self-contained, `'static` owned view of a `CommandOutputReplayRef` message. + + Wraps [`::buffa::OwnedView`]`<`[`CommandOutputReplayRefView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CommandOutputReplayRefView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CommandOutputReplayRefOwnedView( + ::buffa::OwnedView>, +); +impl CommandOutputReplayRefOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CommandOutputReplayRefOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CommandOutputReplayRefOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CommandOutputReplayRef, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CommandOutputReplayRefOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CommandOutputReplayRefView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CommandOutputReplayRefView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CommandOutputReplayRef { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Claim-check to the framed capture. Its `preview` conventionally holds the + /// tail of the output, which is the part someone reading a command log wants + /// first. + /// + /// Field 1: `artifact` + #[must_use] + pub fn artifact( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().artifact + } + /// Version of the byte layout inside the artifact, as defined by + /// trogonai.session.sessions.replay.v1alpha1. + /// + /// Carried as a number and not read out of the artifact's media type, because + /// a reader deciding whether it can parse these frames should not be doing + /// string surgery on a MIME parameter to find out. + /// + /// Field 2: `format_version` + #[must_use] + pub fn format_version(&self) -> u32 { + self.0.reborrow().format_version + } + /// Field 3: `capture_mode` + #[must_use] + pub fn capture_mode(&self) -> ::buffa::EnumValue { + self.0.reborrow().capture_mode + } + /// Field 4: `timing` + #[must_use] + pub fn timing(&self) -> ::buffa::EnumValue { + self.0.reborrow().timing + } + /// Field 5: `completeness` + #[must_use] + pub fn completeness( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ReplayCompletenessView<'_>, + > { + &self.0.reborrow().completeness + } + /// Frames in the capture. + /// + /// Field 6: `frame_count` + #[must_use] + pub fn frame_count(&self) -> u64 { + self.0.reborrow().frame_count + } + /// Payload bytes across all frames, which is the size of the output as a user + /// understands it. Always smaller than ArtifactRef.size_bytes, which includes + /// framing overhead and the index. + /// + /// Field 7: `output_byte_count` + #[must_use] + pub fn output_byte_count(&self) -> u64 { + self.0.reborrow().output_byte_count + } + /// Where the seek index sits inside the artifact. + /// + /// The index is a trailer, because a capturer streaming a running process does + /// not know it until the process exits and so cannot write it as a header. Its + /// location is recorded here so a reader can range-read the index directly, + /// rather than seeking relative to an end-of-object the artifact store might + /// report differently than the log does. + /// + /// Field 8: `index_offset` + #[must_use] + pub fn index_offset(&self) -> u64 { + self.0.reborrow().index_offset + } + /// Field 9: `index_length` + #[must_use] + pub fn index_length(&self) -> u64 { + self.0.reborrow().index_length + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CommandOutputReplayRefOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CommandOutputReplayRefOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CommandOutputReplayRefOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CommandOutputReplayRefOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CommandOutputReplayRef { + type View<'a> = CommandOutputReplayRefView<'a>; + type ViewHandle = CommandOutputReplayRefOwnedView; +} +impl ::serde::Serialize for CommandOutputReplayRefOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReplayCompleteness is how much of the output survived capture. +/// +/// This is not ArtifactRef.truncated, which says a preview is shorter than its +/// content. This says the content is shorter than what the process emitted, and +/// names which end went missing, because for a command log that is the whole +/// question: losing the tail loses the failure, losing the head loses what was +/// run. +#[derive(Clone, Debug, Default)] +pub struct ReplayCompletenessView<'a> { + /// Unspecified is not complete. A reader that cannot recognize the shape must + /// treat the capture as of unknown completeness rather than whole. + /// + /// Field 1: `shape` + pub shape: ::buffa::EnumValue, + /// Payload bytes the capturer saw and did not retain. + /// + /// Unset means dropping occurred and was not counted, which a fixed-size ring + /// buffer that overwrites without accounting cannot avoid. Left absent rather + /// than reported as zero, because zero here would say nothing was lost. + /// + /// Field 2: `dropped_byte_count` + pub dropped_byte_count: ::core::option::Option, + /// Frames the capturer saw and did not retain, under the same rule. + /// + /// Field 3: `dropped_frame_count` + pub dropped_frame_count: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, +} +impl<'a> ReplayCompletenessView<'a> { + /**Whether required field `shape` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_shape(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReplayCompletenessView<'a> { + type Owned = super::super::ReplayCompleteness; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.shape = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.dropped_byte_count = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.dropped_frame_count = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReplayCompleteness { + shape: self.shape, + dropped_byte_count: self.dropped_byte_count, + dropped_frame_count: self.dropped_frame_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReplayCompletenessView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.shape.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.dropped_byte_count { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.dropped_frame_count { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.shape.to_i32(), buf); + if let Some(v) = self.dropped_byte_count { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(v) = self.dropped_frame_count { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReplayCompletenessView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("shape", &self.shape)?; + } + if let ::core::option::Option::Some(__v) = self.dropped_byte_count { + __map + .serialize_entry( + "droppedByteCount", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.dropped_frame_count { + __map + .serialize_entry( + "droppedFrameCount", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReplayCompletenessView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReplayCompleteness"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReplayCompleteness"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReplayCompleteness"; +} +::buffa::impl_default_view_instance!(ReplayCompletenessView); +::buffa::impl_view_reborrow!(ReplayCompletenessView); +/** Self-contained, `'static` owned view of a `ReplayCompleteness` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReplayCompletenessView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReplayCompletenessView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReplayCompletenessOwnedView( + ::buffa::OwnedView>, +); +impl ReplayCompletenessOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayCompletenessOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayCompletenessOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReplayCompleteness, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReplayCompletenessOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReplayCompletenessView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReplayCompletenessView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReplayCompleteness { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Unspecified is not complete. A reader that cannot recognize the shape must + /// treat the capture as of unknown completeness rather than whole. + /// + /// Field 1: `shape` + #[must_use] + pub fn shape(&self) -> ::buffa::EnumValue { + self.0.reborrow().shape + } + /// Payload bytes the capturer saw and did not retain. + /// + /// Unset means dropping occurred and was not counted, which a fixed-size ring + /// buffer that overwrites without accounting cannot avoid. Left absent rather + /// than reported as zero, because zero here would say nothing was lost. + /// + /// Field 2: `dropped_byte_count` + #[must_use] + pub fn dropped_byte_count(&self) -> ::core::option::Option { + self.0.reborrow().dropped_byte_count + } + /// Frames the capturer saw and did not retain, under the same rule. + /// + /// Field 3: `dropped_frame_count` + #[must_use] + pub fn dropped_frame_count(&self) -> ::core::option::Option { + self.0.reborrow().dropped_frame_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReplayCompletenessOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReplayCompletenessOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReplayCompletenessOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReplayCompletenessOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReplayCompleteness { + type View<'a> = ReplayCompletenessView<'a>; + type ViewHandle = ReplayCompletenessOwnedView; +} +impl ::serde::Serialize for ReplayCompletenessOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.rs new file mode 100644 index 0000000000..535a6556c2 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.command_output_replay.rs @@ -0,0 +1,1044 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/command_output_replay.proto + +/// CaptureMode is how the output was collected, which decides what the frame +/// order and the per-frame stream tag are actually worth. +/// +/// A renderer that ignores this will misrepresent output in one of two +/// directions, and which one depends on a decision made at spawn time that it +/// cannot see. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum CaptureMode { + CAPTURE_MODE_UNSPECIFIED = 0i32, + /// stdout and stderr were read from separate pipes. + /// + /// Stream attribution is exact and the interleaving is not: the child's own + /// buffering decides when each pipe becomes readable, so a line written to + /// stderr before a line written to stdout can be captured after it. A renderer + /// may color the two streams and must not present their relative order as the + /// order the process produced them in. + CAPTURE_MODE_SEPARATE_PIPES = 1i32, + /// Both streams were written to one terminal or one pipe. + /// + /// The interleaving is the process's own and is exact. Stream attribution is + /// gone: the frames say MERGED because at capture time there was nothing left + /// to distinguish. A renderer must not guess stderr from content, which is + /// what makes this the honest opposite of SEPARATE_PIPES rather than a + /// strictly worse version of it. + CAPTURE_MODE_MERGED_TERMINAL = 2i32, +} +impl CaptureMode { + ///Idiomatic alias for [`Self::CAPTURE_MODE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CAPTURE_MODE_UNSPECIFIED; + ///Idiomatic alias for [`Self::CAPTURE_MODE_SEPARATE_PIPES`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SeparatePipes: Self = Self::CAPTURE_MODE_SEPARATE_PIPES; + ///Idiomatic alias for [`Self::CAPTURE_MODE_MERGED_TERMINAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MergedTerminal: Self = Self::CAPTURE_MODE_MERGED_TERMINAL; +} +impl ::core::default::Default for CaptureMode { + fn default() -> Self { + Self::CAPTURE_MODE_UNSPECIFIED + } +} +impl ::serde::Serialize for CaptureMode { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for CaptureMode { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = CaptureMode; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(CaptureMode)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for CaptureMode { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for CaptureMode { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CAPTURE_MODE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CAPTURE_MODE_SEPARATE_PIPES), + 2i32 => ::core::option::Option::Some(Self::CAPTURE_MODE_MERGED_TERMINAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CAPTURE_MODE_UNSPECIFIED => "CAPTURE_MODE_UNSPECIFIED", + Self::CAPTURE_MODE_SEPARATE_PIPES => "CAPTURE_MODE_SEPARATE_PIPES", + Self::CAPTURE_MODE_MERGED_TERMINAL => "CAPTURE_MODE_MERGED_TERMINAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CAPTURE_MODE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CAPTURE_MODE_UNSPECIFIED) + } + "CAPTURE_MODE_SEPARATE_PIPES" => { + ::core::option::Option::Some(Self::CAPTURE_MODE_SEPARATE_PIPES) + } + "CAPTURE_MODE_MERGED_TERMINAL" => { + ::core::option::Option::Some(Self::CAPTURE_MODE_MERGED_TERMINAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CAPTURE_MODE_UNSPECIFIED, + Self::CAPTURE_MODE_SEPARATE_PIPES, + Self::CAPTURE_MODE_MERGED_TERMINAL, + ] + } +} +/// TimingFidelity is whether the capture can be played back at speed, or only in +/// order. +/// +/// Order-only is the common case and the safe default, and it is stated rather +/// than left to inference because a replay UI that animates untimed frames is +/// inventing pacing and presenting it as a recording. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TimingFidelity { + TIMING_FIDELITY_UNSPECIFIED = 0i32, + /// Frames carry no timing. Only their sequence is meaningful. + TIMING_FIDELITY_ORDER_ONLY = 1i32, + /// Frames carry the elapsed time at which the capturer observed them, which is + /// not when the process wrote them: pipe buffering, scheduler delay, and the + /// capturer's own read loop all sit in between. Close enough to replay at + /// speed, not evidence of when anything happened. + TIMING_FIDELITY_CAPTURE_ELAPSED = 2i32, +} +impl TimingFidelity { + ///Idiomatic alias for [`Self::TIMING_FIDELITY_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TIMING_FIDELITY_UNSPECIFIED; + ///Idiomatic alias for [`Self::TIMING_FIDELITY_ORDER_ONLY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const OrderOnly: Self = Self::TIMING_FIDELITY_ORDER_ONLY; + ///Idiomatic alias for [`Self::TIMING_FIDELITY_CAPTURE_ELAPSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CaptureElapsed: Self = Self::TIMING_FIDELITY_CAPTURE_ELAPSED; +} +impl ::core::default::Default for TimingFidelity { + fn default() -> Self { + Self::TIMING_FIDELITY_UNSPECIFIED + } +} +impl ::serde::Serialize for TimingFidelity { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TimingFidelity { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TimingFidelity; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TimingFidelity) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TimingFidelity { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TimingFidelity { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TIMING_FIDELITY_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TIMING_FIDELITY_ORDER_ONLY), + 2i32 => ::core::option::Option::Some(Self::TIMING_FIDELITY_CAPTURE_ELAPSED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TIMING_FIDELITY_UNSPECIFIED => "TIMING_FIDELITY_UNSPECIFIED", + Self::TIMING_FIDELITY_ORDER_ONLY => "TIMING_FIDELITY_ORDER_ONLY", + Self::TIMING_FIDELITY_CAPTURE_ELAPSED => "TIMING_FIDELITY_CAPTURE_ELAPSED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TIMING_FIDELITY_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TIMING_FIDELITY_UNSPECIFIED) + } + "TIMING_FIDELITY_ORDER_ONLY" => { + ::core::option::Option::Some(Self::TIMING_FIDELITY_ORDER_ONLY) + } + "TIMING_FIDELITY_CAPTURE_ELAPSED" => { + ::core::option::Option::Some(Self::TIMING_FIDELITY_CAPTURE_ELAPSED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TIMING_FIDELITY_UNSPECIFIED, + Self::TIMING_FIDELITY_ORDER_ONLY, + Self::TIMING_FIDELITY_CAPTURE_ELAPSED, + ] + } +} +/// TruncationShape is which part of the output is missing. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TruncationShape { + TRUNCATION_SHAPE_UNSPECIFIED = 0i32, + /// Everything the process emitted was captured. + TRUNCATION_SHAPE_COMPLETE = 1i32, + /// The beginning was dropped, typically by a ring buffer that kept the most + /// recent output. The command's own startup and its invocation echo are gone. + TRUNCATION_SHAPE_HEAD_DROPPED = 2i32, + /// Capture stopped at a cap and the rest was discarded. Whatever the command + /// said on its way out, including why it failed, is not here. + TRUNCATION_SHAPE_TAIL_DROPPED = 3i32, + /// The head and the tail were kept and a span in the middle was not. Frame + /// sequence numbers are the capturer's original count and are never compacted + /// when frames are dropped, so the gap is visible in the frames themselves; + /// this value is what lets a reader know to expect one without scanning for + /// it. + TRUNCATION_SHAPE_MIDDLE_DROPPED = 4i32, +} +impl TruncationShape { + ///Idiomatic alias for [`Self::TRUNCATION_SHAPE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TRUNCATION_SHAPE_UNSPECIFIED; + ///Idiomatic alias for [`Self::TRUNCATION_SHAPE_COMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Complete: Self = Self::TRUNCATION_SHAPE_COMPLETE; + ///Idiomatic alias for [`Self::TRUNCATION_SHAPE_HEAD_DROPPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const HeadDropped: Self = Self::TRUNCATION_SHAPE_HEAD_DROPPED; + ///Idiomatic alias for [`Self::TRUNCATION_SHAPE_TAIL_DROPPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const TailDropped: Self = Self::TRUNCATION_SHAPE_TAIL_DROPPED; + ///Idiomatic alias for [`Self::TRUNCATION_SHAPE_MIDDLE_DROPPED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MiddleDropped: Self = Self::TRUNCATION_SHAPE_MIDDLE_DROPPED; +} +impl ::core::default::Default for TruncationShape { + fn default() -> Self { + Self::TRUNCATION_SHAPE_UNSPECIFIED + } +} +impl ::serde::Serialize for TruncationShape { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TruncationShape { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TruncationShape; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TruncationShape) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TruncationShape { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TruncationShape { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TRUNCATION_SHAPE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TRUNCATION_SHAPE_COMPLETE), + 2i32 => ::core::option::Option::Some(Self::TRUNCATION_SHAPE_HEAD_DROPPED), + 3i32 => ::core::option::Option::Some(Self::TRUNCATION_SHAPE_TAIL_DROPPED), + 4i32 => ::core::option::Option::Some(Self::TRUNCATION_SHAPE_MIDDLE_DROPPED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TRUNCATION_SHAPE_UNSPECIFIED => "TRUNCATION_SHAPE_UNSPECIFIED", + Self::TRUNCATION_SHAPE_COMPLETE => "TRUNCATION_SHAPE_COMPLETE", + Self::TRUNCATION_SHAPE_HEAD_DROPPED => "TRUNCATION_SHAPE_HEAD_DROPPED", + Self::TRUNCATION_SHAPE_TAIL_DROPPED => "TRUNCATION_SHAPE_TAIL_DROPPED", + Self::TRUNCATION_SHAPE_MIDDLE_DROPPED => "TRUNCATION_SHAPE_MIDDLE_DROPPED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TRUNCATION_SHAPE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TRUNCATION_SHAPE_UNSPECIFIED) + } + "TRUNCATION_SHAPE_COMPLETE" => { + ::core::option::Option::Some(Self::TRUNCATION_SHAPE_COMPLETE) + } + "TRUNCATION_SHAPE_HEAD_DROPPED" => { + ::core::option::Option::Some(Self::TRUNCATION_SHAPE_HEAD_DROPPED) + } + "TRUNCATION_SHAPE_TAIL_DROPPED" => { + ::core::option::Option::Some(Self::TRUNCATION_SHAPE_TAIL_DROPPED) + } + "TRUNCATION_SHAPE_MIDDLE_DROPPED" => { + ::core::option::Option::Some(Self::TRUNCATION_SHAPE_MIDDLE_DROPPED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TRUNCATION_SHAPE_UNSPECIFIED, + Self::TRUNCATION_SHAPE_COMPLETE, + Self::TRUNCATION_SHAPE_HEAD_DROPPED, + Self::TRUNCATION_SHAPE_TAIL_DROPPED, + Self::TRUNCATION_SHAPE_MIDDLE_DROPPED, + ] + } +} +/// CommandOutputReplayRef is a claim-check to the captured output of a +/// process-executing tool call, plus the small set of facts a reader needs +/// before it is allowed to render any of it. +/// +/// The output itself is an artifact: one immutable, content-addressed blob of +/// framed stdout and stderr, referenced from the terminal event rather than +/// appended to the log as an event per chunk. A long command emits millions of +/// writes, and a log that records them is a log whose size is set by the noisiest +/// thing that ever ran on it, permanently, because nothing ever leaves the log +/// (ADR#0035 facet 7). +/// +/// It lives on ToolCallCompleted, next to CommandTermination and for the same +/// reason (D11): it is the execution and audit record, not the transcript the +/// model received. The model saw ToolCallResult, which is usually a truncation +/// or a summary. Putting raw captured output into the replay shape would feed a +/// later turn context the original turn never had. +/// +/// Every field here is on the log rather than only inside the artifact, because +/// the artifact's bytes may be erased (ArtifactErased) while the log keeps its +/// provenance. After erasure a reader can still say the command produced 2.1 +/// million frames and 40 MB and was captured through a terminal, which is the +/// point of separating byte lifecycle from log retention. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CommandOutputReplayRef { + /// Claim-check to the framed capture. Its `preview` conventionally holds the + /// tail of the output, which is the part someone reading a command log wants + /// first. + /// + /// Field 1: `artifact` + #[serde(rename = "artifact")] + pub artifact: ::buffa::MessageField>, + /// Version of the byte layout inside the artifact, as defined by + /// trogonai.session.sessions.replay.v1alpha1. + /// + /// Carried as a number and not read out of the artifact's media type, because + /// a reader deciding whether it can parse these frames should not be doing + /// string surgery on a MIME parameter to find out. + /// + /// Field 2: `format_version` + #[serde( + rename = "formatVersion", + alias = "format_version", + with = "::buffa::json_helpers::uint32" + )] + pub format_version: u32, + /// Field 3: `capture_mode` + #[serde( + rename = "captureMode", + alias = "capture_mode", + with = "::buffa::json_helpers::proto_enum" + )] + pub capture_mode: ::buffa::EnumValue, + /// Field 4: `timing` + #[serde(rename = "timing", with = "::buffa::json_helpers::proto_enum")] + pub timing: ::buffa::EnumValue, + /// Field 5: `completeness` + #[serde(rename = "completeness")] + pub completeness: ::buffa::MessageField< + ReplayCompleteness, + ::buffa::Inline, + >, + /// Frames in the capture. + /// + /// Field 6: `frame_count` + #[serde( + rename = "frameCount", + alias = "frame_count", + with = "::buffa::json_helpers::uint64" + )] + pub frame_count: u64, + /// Payload bytes across all frames, which is the size of the output as a user + /// understands it. Always smaller than ArtifactRef.size_bytes, which includes + /// framing overhead and the index. + /// + /// Field 7: `output_byte_count` + #[serde( + rename = "outputByteCount", + alias = "output_byte_count", + with = "::buffa::json_helpers::uint64" + )] + pub output_byte_count: u64, + /// Where the seek index sits inside the artifact. + /// + /// The index is a trailer, because a capturer streaming a running process does + /// not know it until the process exits and so cannot write it as a header. Its + /// location is recorded here so a reader can range-read the index directly, + /// rather than seeking relative to an end-of-object the artifact store might + /// report differently than the log does. + /// + /// Field 8: `index_offset` + #[serde( + rename = "indexOffset", + alias = "index_offset", + with = "::buffa::json_helpers::uint64" + )] + pub index_offset: u64, + /// Field 9: `index_length` + #[serde( + rename = "indexLength", + alias = "index_length", + with = "::buffa::json_helpers::uint64" + )] + pub index_length: u64, +} +impl ::core::fmt::Debug for CommandOutputReplayRef { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CommandOutputReplayRef") + .field("artifact", &self.artifact) + .field("format_version", &self.format_version) + .field("capture_mode", &self.capture_mode) + .field("timing", &self.timing) + .field("completeness", &self.completeness) + .field("frame_count", &self.frame_count) + .field("output_byte_count", &self.output_byte_count) + .field("index_offset", &self.index_offset) + .field("index_length", &self.index_length) + .finish() + } +} +impl CommandOutputReplayRef { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CommandOutputReplayRef"; +} +::buffa::impl_default_instance!(CommandOutputReplayRef); +impl ::buffa::MessageName for CommandOutputReplayRef { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CommandOutputReplayRef"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CommandOutputReplayRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CommandOutputReplayRef"; +} +impl ::buffa::Message for CommandOutputReplayRef { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.artifact.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifact.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.format_version) as u64; + { + let val = self.capture_mode.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + { + let val = self.timing.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.completeness.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.completeness.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.frame_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.output_byte_count) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.index_offset) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.index_length) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.artifact.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifact.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(2u32, self.format_version, buf); + ::buffa::types::put_int32_field(3u32, self.capture_mode.to_i32(), buf); + ::buffa::types::put_int32_field(4u32, self.timing.to_i32(), buf); + if self.completeness.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.completeness.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(6u32, self.frame_count, buf); + ::buffa::types::put_uint64_field(7u32, self.output_byte_count, buf); + ::buffa::types::put_uint64_field(8u32, self.index_offset, buf); + ::buffa::types::put_uint64_field(9u32, self.index_length, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.artifact.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.format_version = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.capture_mode = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.timing = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.completeness.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.frame_count = ::buffa::types::decode_uint64(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.output_byte_count = ::buffa::types::decode_uint64(buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.index_offset = ::buffa::types::decode_uint64(buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.index_length = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.artifact = ::buffa::MessageField::none(); + self.format_version = 0u32; + self.capture_mode = ::buffa::EnumValue::from(0); + self.timing = ::buffa::EnumValue::from(0); + self.completeness = ::buffa::MessageField::none(); + self.frame_count = 0u64; + self.output_byte_count = 0u64; + self.index_offset = 0u64; + self.index_length = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CommandOutputReplayRef { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMMAND_OUTPUT_REPLAY_REF_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CommandOutputReplayRef", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReplayCompleteness is how much of the output survived capture. +/// +/// This is not ArtifactRef.truncated, which says a preview is shorter than its +/// content. This says the content is shorter than what the process emitted, and +/// names which end went missing, because for a command log that is the whole +/// question: losing the tail loses the failure, losing the head loses what was +/// run. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReplayCompleteness { + /// Unspecified is not complete. A reader that cannot recognize the shape must + /// treat the capture as of unknown completeness rather than whole. + /// + /// Field 1: `shape` + #[serde(rename = "shape", with = "::buffa::json_helpers::proto_enum")] + pub shape: ::buffa::EnumValue, + /// Payload bytes the capturer saw and did not retain. + /// + /// Unset means dropping occurred and was not counted, which a fixed-size ring + /// buffer that overwrites without accounting cannot avoid. Left absent rather + /// than reported as zero, because zero here would say nothing was lost. + /// + /// Field 2: `dropped_byte_count` + #[serde( + rename = "droppedByteCount", + alias = "dropped_byte_count", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub dropped_byte_count: ::core::option::Option, + /// Frames the capturer saw and did not retain, under the same rule. + /// + /// Field 3: `dropped_frame_count` + #[serde( + rename = "droppedFrameCount", + alias = "dropped_frame_count", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub dropped_frame_count: ::core::option::Option, +} +impl ::core::fmt::Debug for ReplayCompleteness { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReplayCompleteness") + .field("shape", &self.shape) + .field("dropped_byte_count", &self.dropped_byte_count) + .field("dropped_frame_count", &self.dropped_frame_count) + .finish() + } +} +impl ReplayCompleteness { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReplayCompleteness"; +} +impl ReplayCompleteness { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::dropped_byte_count`] to `Some(value)`, consuming and returning `self`. + pub fn with_dropped_byte_count(mut self, value: u64) -> Self { + self.dropped_byte_count = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::dropped_frame_count`] to `Some(value)`, consuming and returning `self`. + pub fn with_dropped_frame_count(mut self, value: u64) -> Self { + self.dropped_frame_count = Some(value); + self + } +} +::buffa::impl_default_instance!(ReplayCompleteness); +impl ::buffa::MessageName for ReplayCompleteness { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReplayCompleteness"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReplayCompleteness"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReplayCompleteness"; +} +impl ::buffa::Message for ReplayCompleteness { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.shape.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(v) = self.dropped_byte_count { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.dropped_frame_count { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.shape.to_i32(), buf); + if let Some(v) = self.dropped_byte_count { + ::buffa::types::put_uint64_field(2u32, v, buf); + } + if let Some(v) = self.dropped_frame_count { + ::buffa::types::put_uint64_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.shape = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.dropped_byte_count = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.dropped_frame_count = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.shape = ::buffa::EnumValue::from(0); + self.dropped_byte_count = ::core::option::Option::None; + self.dropped_frame_count = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReplayCompleteness { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REPLAY_COMPLETENESS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReplayCompleteness", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.__view.rs new file mode 100644 index 0000000000..96029e02e9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.__view.rs @@ -0,0 +1,885 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/compact_session.proto + +/// CompactSession replaces a covered span of history with a summary, recording +/// \[Compacted\]. The command carries the summary its producer generated; the +/// aggregate decides whether that cut is admissible. +/// +/// Write precondition At. The heaviest invariant set in the aggregate: the cut +/// must start at the context root, land between complete turn groups, leave a +/// non-empty complete-turn tail, include the prior usable marker, match the +/// plan-versioned covered input digest, and come from the current Ready attempt +/// (ADR#0035 facet 4). +#[derive(Clone, Debug, Default)] +pub struct CompactSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `summary_id` + pub summary_id: &'a str, + /// Field 3: `summary_content` + pub summary_content: &'a str, + /// Field 4: `covers_from` + pub covers_from: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 5: `covers_through` + pub covers_through: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 6: `trigger` + pub trigger: ::buffa::EnumValue, + /// Field 7: `guidance` + pub guidance: ::core::option::Option<&'a str>, + /// Field 8: `tokens_before` + pub tokens_before: ::core::option::Option, + /// Field 9: `tokens_after` + pub tokens_after: ::core::option::Option, + /// Field 10: `model` + pub model: ::core::option::Option<&'a str>, + /// Field 11: `usage` + pub usage: ::buffa::MessageFieldView< + super::super::__buffa::view::TokenUsageView<'a>, + >, + /// Field 12: `context_root` + pub context_root: ::buffa::MessageFieldView< + super::super::__buffa::view::CompactionContextRootView<'a>, + >, + /// Field 13: `producer` + pub producer: ::buffa::MessageFieldView< + super::super::__buffa::view::CompactionProducerView<'a>, + >, + /// Digest over the plan-versioned covered input, recomputed and compared + /// before the cut is admitted. + /// + /// Field 14: `covered_input_digest` + pub covered_input_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CompactSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `summary_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `summary_content` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_summary_content(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `covers_from` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_from(&self) -> bool { + self.covers_from.is_set() + } + /**Whether required field `covers_through` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covers_through(&self) -> bool { + self.covers_through.is_set() + } + /**Whether required field `trigger` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_trigger(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `context_root` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_context_root(&self) -> bool { + self.context_root.is_set() + } + /**Whether required field `producer` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_producer(&self) -> bool { + self.producer.is_set() + } + /**Whether required field `covered_input_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_covered_input_digest(&self) -> bool { + self.covered_input_digest.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CompactSessionView<'a> { + type Owned = super::super::CompactSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.summary_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.summary_content = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covers_from.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covers_from = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covers_through.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covers_through = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.trigger = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.guidance = Some(::buffa::types::borrow_str(&mut cur)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.tokens_before = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.tokens_after = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.model = Some(::buffa::types::borrow_str(&mut cur)?); + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.usage.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.usage = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.context_root.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.context_root = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.producer.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.producer = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 14u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.covered_input_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.covered_input_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CompactSession { + session_id: self.session_id.to_string(), + summary_id: self.summary_id.to_string(), + summary_content: self.summary_content.to_string(), + covers_from: match self.covers_from.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + covers_through: match self.covers_through.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + trigger: self.trigger, + guidance: self.guidance.map(|s| s.to_string()), + tokens_before: self.tokens_before, + tokens_after: self.tokens_after, + model: self.model.map(|s| s.to_string()), + usage: match self.usage.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::TokenUsage, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + context_root: match self.context_root.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CompactionContextRoot, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + producer: match self.producer.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CompactionProducer, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + covered_input_digest: match self.covered_input_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CompactSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_content) as u64; + if self.covers_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.trigger.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.guidance { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.tokens_before { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.tokens_after { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.model { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.context_root.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_root.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.producer.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.producer.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covered_input_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covered_input_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.summary_id, buf); + ::buffa::types::put_string_field(3u32, &self.summary_content, buf); + if self.covers_from.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_from.write_to(__cache, buf); + } + if self.covers_through.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_through.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.trigger.to_i32(), buf); + if let Some(ref v) = self.guidance { + ::buffa::types::put_string_field(7u32, v, buf); + } + if let Some(v) = self.tokens_before { + ::buffa::types::put_uint64_field(8u32, v, buf); + } + if let Some(v) = self.tokens_after { + ::buffa::types::put_uint64_field(9u32, v, buf); + } + if let Some(ref v) = self.model { + ::buffa::types::put_string_field(10u32, v, buf); + } + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + if self.context_root.is_set() { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_root.write_to(__cache, buf); + } + if self.producer.is_set() { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + self.producer.write_to(__cache, buf); + } + if self.covered_input_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 14u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covered_input_digest.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CompactSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("summaryId", self.summary_id)?; + } + { + __map.serialize_entry("summaryContent", self.summary_content)?; + } + { + if let ::core::option::Option::Some(__v) = self.covers_from.as_option() { + __map.serialize_entry("coversFrom", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.covers_through.as_option() { + __map.serialize_entry("coversThrough", __v)?; + } + } + { + __map.serialize_entry("trigger", &self.trigger)?; + } + if let ::core::option::Option::Some(__v) = self.guidance { + __map.serialize_entry("guidance", __v)?; + } + if let ::core::option::Option::Some(__v) = self.tokens_before { + __map + .serialize_entry( + "tokensBefore", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.tokens_after { + __map + .serialize_entry( + "tokensAfter", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + if let ::core::option::Option::Some(__v) = self.model { + __map.serialize_entry("model", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.usage.as_option() { + __map.serialize_entry("usage", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.context_root.as_option() { + __map.serialize_entry("contextRoot", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.producer.as_option() { + __map.serialize_entry("producer", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .covered_input_digest + .as_option() + { + __map.serialize_entry("coveredInputDigest", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CompactSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompactSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompactSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompactSession"; +} +::buffa::impl_default_view_instance!(CompactSessionView); +::buffa::impl_view_reborrow!(CompactSessionView); +/** Self-contained, `'static` owned view of a `CompactSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`CompactSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CompactSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CompactSessionOwnedView(::buffa::OwnedView>); +impl CompactSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactSessionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CompactSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompactSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CompactSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CompactSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CompactSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `summary_id` + #[must_use] + pub fn summary_id(&self) -> &'_ str { + self.0.reborrow().summary_id + } + /// Field 3: `summary_content` + #[must_use] + pub fn summary_content(&self) -> &'_ str { + self.0.reborrow().summary_content + } + /// Field 4: `covers_from` + #[must_use] + pub fn covers_from( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().covers_from + } + /// Field 5: `covers_through` + #[must_use] + pub fn covers_through( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().covers_through + } + /// Field 6: `trigger` + #[must_use] + pub fn trigger(&self) -> ::buffa::EnumValue { + self.0.reborrow().trigger + } + /// Field 7: `guidance` + #[must_use] + pub fn guidance(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().guidance + } + /// Field 8: `tokens_before` + #[must_use] + pub fn tokens_before(&self) -> ::core::option::Option { + self.0.reborrow().tokens_before + } + /// Field 9: `tokens_after` + #[must_use] + pub fn tokens_after(&self) -> ::core::option::Option { + self.0.reborrow().tokens_after + } + /// Field 10: `model` + #[must_use] + pub fn model(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().model + } + /// Field 11: `usage` + #[must_use] + pub fn usage( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().usage + } + /// Field 12: `context_root` + #[must_use] + pub fn context_root( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CompactionContextRootView<'_>, + > { + &self.0.reborrow().context_root + } + /// Field 13: `producer` + #[must_use] + pub fn producer( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CompactionProducerView<'_>, + > { + &self.0.reborrow().producer + } + /// Digest over the plan-versioned covered input, recomputed and compared + /// before the cut is admitted. + /// + /// Field 14: `covered_input_digest` + #[must_use] + pub fn covered_input_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().covered_input_digest + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CompactSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CompactSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CompactSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CompactSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CompactSession { + type View<'a> = CompactSessionView<'a>; + type ViewHandle = CompactSessionOwnedView; +} +impl ::serde::Serialize for CompactSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.rs new file mode 100644 index 0000000000..3e4d1c6d9c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.compact_session.rs @@ -0,0 +1,516 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/compact_session.proto + +/// CompactSession replaces a covered span of history with a summary, recording +/// \[Compacted\]. The command carries the summary its producer generated; the +/// aggregate decides whether that cut is admissible. +/// +/// Write precondition At. The heaviest invariant set in the aggregate: the cut +/// must start at the context root, land between complete turn groups, leave a +/// non-empty complete-turn tail, include the prior usable marker, match the +/// plan-versioned covered input digest, and come from the current Ready attempt +/// (ADR#0035 facet 4). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CompactSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `summary_id` + #[serde( + rename = "summaryId", + alias = "summary_id", + with = "::buffa::json_helpers::proto_string" + )] + pub summary_id: ::buffa::alloc::string::String, + /// Field 3: `summary_content` + #[serde( + rename = "summaryContent", + alias = "summary_content", + with = "::buffa::json_helpers::proto_string" + )] + pub summary_content: ::buffa::alloc::string::String, + /// Field 4: `covers_from` + #[serde(rename = "coversFrom", alias = "covers_from")] + pub covers_from: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 5: `covers_through` + #[serde(rename = "coversThrough", alias = "covers_through")] + pub covers_through: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 6: `trigger` + #[serde(rename = "trigger", with = "::buffa::json_helpers::proto_enum")] + pub trigger: ::buffa::EnumValue, + /// Field 7: `guidance` + #[serde( + rename = "guidance", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub guidance: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 8: `tokens_before` + #[serde( + rename = "tokensBefore", + alias = "tokens_before", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub tokens_before: ::core::option::Option, + /// Field 9: `tokens_after` + #[serde( + rename = "tokensAfter", + alias = "tokens_after", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub tokens_after: ::core::option::Option, + /// Field 10: `model` + #[serde(rename = "model", skip_serializing_if = "::core::option::Option::is_none")] + pub model: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 11: `usage` + #[serde( + rename = "usage", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub usage: ::buffa::MessageField>, + /// Field 12: `context_root` + #[serde(rename = "contextRoot", alias = "context_root")] + pub context_root: ::buffa::MessageField< + CompactionContextRoot, + ::buffa::Inline, + >, + /// Field 13: `producer` + #[serde(rename = "producer")] + pub producer: ::buffa::MessageField< + CompactionProducer, + ::buffa::Inline, + >, + /// Digest over the plan-versioned covered input, recomputed and compared + /// before the cut is admitted. + /// + /// Field 14: `covered_input_digest` + #[serde(rename = "coveredInputDigest", alias = "covered_input_digest")] + pub covered_input_digest: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for CompactSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CompactSession") + .field("session_id", &self.session_id) + .field("summary_id", &self.summary_id) + .field("summary_content", &self.summary_content) + .field("covers_from", &self.covers_from) + .field("covers_through", &self.covers_through) + .field("trigger", &self.trigger) + .field("guidance", &self.guidance) + .field("tokens_before", &self.tokens_before) + .field("tokens_after", &self.tokens_after) + .field("model", &self.model) + .field("usage", &self.usage) + .field("context_root", &self.context_root) + .field("producer", &self.producer) + .field("covered_input_digest", &self.covered_input_digest) + .finish() + } +} +impl CompactSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompactSession"; +} +impl CompactSession { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::guidance`] to `Some(value)`, consuming and returning `self`. + pub fn with_guidance( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.guidance = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::tokens_before`] to `Some(value)`, consuming and returning `self`. + pub fn with_tokens_before(mut self, value: u64) -> Self { + self.tokens_before = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::tokens_after`] to `Some(value)`, consuming and returning `self`. + pub fn with_tokens_after(mut self, value: u64) -> Self { + self.tokens_after = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::model`] to `Some(value)`, consuming and returning `self`. + pub fn with_model( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.model = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(CompactSession); +impl ::buffa::MessageName for CompactSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompactSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompactSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompactSession"; +} +impl ::buffa::Message for CompactSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.summary_content) as u64; + if self.covers_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covers_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covers_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.trigger.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.guidance { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(v) = self.tokens_before { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(v) = self.tokens_after { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + if let Some(ref v) = self.model { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.context_root.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_root.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.producer.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.producer.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.covered_input_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.covered_input_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.summary_id, buf); + ::buffa::types::put_string_field(3u32, &self.summary_content, buf); + if self.covers_from.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_from.write_to(__cache, buf); + } + if self.covers_through.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covers_through.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.trigger.to_i32(), buf); + if let Some(ref v) = self.guidance { + ::buffa::types::put_string_field(7u32, v, buf); + } + if let Some(v) = self.tokens_before { + ::buffa::types::put_uint64_field(8u32, v, buf); + } + if let Some(v) = self.tokens_after { + ::buffa::types::put_uint64_field(9u32, v, buf); + } + if let Some(ref v) = self.model { + ::buffa::types::put_string_field(10u32, v, buf); + } + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + if self.context_root.is_set() { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_root.write_to(__cache, buf); + } + if self.producer.is_set() { + ::buffa::types::put_len_delimited_header( + 13u32, + u64::from(__cache.consume_next()), + buf, + ); + self.producer.write_to(__cache, buf); + } + if self.covered_input_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 14u32, + u64::from(__cache.consume_next()), + buf, + ); + self.covered_input_digest.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.summary_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.summary_content, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covers_from.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covers_through.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.trigger = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .guidance + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.tokens_before = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.tokens_after = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.model.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.usage.get_or_insert_default(), + buf, + ctx, + )?; + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.context_root.get_or_insert_default(), + buf, + ctx, + )?; + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.producer.get_or_insert_default(), + buf, + ctx, + )?; + } + 14u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.covered_input_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.summary_id.clear(); + self.summary_content.clear(); + self.covers_from = ::buffa::MessageField::none(); + self.covers_through = ::buffa::MessageField::none(); + self.trigger = ::buffa::EnumValue::from(0); + self.guidance = ::core::option::Option::None; + self.tokens_before = ::core::option::Option::None; + self.tokens_after = ::core::option::Option::None; + self.model = ::core::option::Option::None; + self.usage = ::buffa::MessageField::none(); + self.context_root = ::buffa::MessageField::none(); + self.producer = ::buffa::MessageField::none(); + self.covered_input_digest = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CompactSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMPACT_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompactSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.__view.rs new file mode 100644 index 0000000000..6f7cae01ab --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.__view.rs @@ -0,0 +1,428 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/complete_assistant_message.proto + +/// CompleteAssistantMessage settles an assistant turn normally, recording +/// \[AssistantMessageCompleted\]. +/// +/// Write precondition Any: per message_id this competes with +/// FailAssistantMessage under first-terminal-outcome-wins, so ordering between +/// them is decided by the fold rather than by a write guard. +#[derive(Clone, Debug, Default)] +pub struct CompleteAssistantMessageView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `message` + pub message: ::buffa::MessageFieldView< + super::super::__buffa::view::CanonicalMessageView<'a>, + >, + /// Field 3: `finish_reason` + pub finish_reason: ::buffa::EnumValue, + /// Set only when finish_reason is FINISH_REASON_STOP_SEQUENCE. + /// + /// Field 4: `matched_stop_sequence` + pub matched_stop_sequence: ::core::option::Option<&'a str>, + /// Field 5: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CompleteAssistantMessageView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.message.is_set() + } + /**Whether required field `finish_reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_finish_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CompleteAssistantMessageView<'a> { + type Owned = super::super::CompleteAssistantMessage; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.message.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.message = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.finish_reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.matched_stop_sequence = Some(::buffa::types::borrow_str(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::CompleteAssistantMessage, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::CompleteAssistantMessage, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CompleteAssistantMessage { + session_id: self.session_id.to_string(), + message: match self.message.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CanonicalMessage, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + finish_reason: self.finish_reason, + matched_stop_sequence: self.matched_stop_sequence.map(|s| s.to_string()), + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CompleteAssistantMessageView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.finish_reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.matched_stop_sequence { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.message.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.message.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.finish_reason.to_i32(), buf); + if let Some(ref v) = self.matched_stop_sequence { + ::buffa::types::put_string_field(4u32, v, buf); + } + ::buffa::types::put_string_field(5u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CompleteAssistantMessageView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.message.as_option() { + __map.serialize_entry("message", __v)?; + } + } + { + __map.serialize_entry("finishReason", &self.finish_reason)?; + } + if let ::core::option::Option::Some(__v) = self.matched_stop_sequence { + __map.serialize_entry("matchedStopSequence", __v)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CompleteAssistantMessageView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompleteAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompleteAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteAssistantMessage"; +} +::buffa::impl_default_view_instance!(CompleteAssistantMessageView); +::buffa::impl_view_reborrow!(CompleteAssistantMessageView); +/** Self-contained, `'static` owned view of a `CompleteAssistantMessage` message. + + Wraps [`::buffa::OwnedView`]`<`[`CompleteAssistantMessageView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CompleteAssistantMessageView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CompleteAssistantMessageOwnedView( + ::buffa::OwnedView>, +); +impl CompleteAssistantMessageOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteAssistantMessageOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteAssistantMessageOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CompleteAssistantMessage, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteAssistantMessageOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CompleteAssistantMessageView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CompleteAssistantMessageView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CompleteAssistantMessage { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `message` + #[must_use] + pub fn message( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CanonicalMessageView<'_>, + > { + &self.0.reborrow().message + } + /// Field 3: `finish_reason` + #[must_use] + pub fn finish_reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().finish_reason + } + /// Set only when finish_reason is FINISH_REASON_STOP_SEQUENCE. + /// + /// Field 4: `matched_stop_sequence` + #[must_use] + pub fn matched_stop_sequence(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().matched_stop_sequence + } + /// Field 5: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CompleteAssistantMessageOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CompleteAssistantMessageOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CompleteAssistantMessageOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CompleteAssistantMessageOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CompleteAssistantMessage { + type View<'a> = CompleteAssistantMessageView<'a>; + type ViewHandle = CompleteAssistantMessageOwnedView; +} +impl ::serde::Serialize for CompleteAssistantMessageOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.rs new file mode 100644 index 0000000000..854e78c2ea --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_assistant_message.rs @@ -0,0 +1,232 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/complete_assistant_message.proto + +/// CompleteAssistantMessage settles an assistant turn normally, recording +/// \[AssistantMessageCompleted\]. +/// +/// Write precondition Any: per message_id this competes with +/// FailAssistantMessage under first-terminal-outcome-wins, so ordering between +/// them is decided by the fold rather than by a write guard. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CompleteAssistantMessage { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `message` + #[serde(rename = "message")] + pub message: ::buffa::MessageField< + CanonicalMessage, + ::buffa::Inline, + >, + /// Field 3: `finish_reason` + #[serde( + rename = "finishReason", + alias = "finish_reason", + with = "::buffa::json_helpers::proto_enum" + )] + pub finish_reason: ::buffa::EnumValue, + /// Set only when finish_reason is FINISH_REASON_STOP_SEQUENCE. + /// + /// Field 4: `matched_stop_sequence` + #[serde( + rename = "matchedStopSequence", + alias = "matched_stop_sequence", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub matched_stop_sequence: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 5: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for CompleteAssistantMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CompleteAssistantMessage") + .field("session_id", &self.session_id) + .field("message", &self.message) + .field("finish_reason", &self.finish_reason) + .field("matched_stop_sequence", &self.matched_stop_sequence) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl CompleteAssistantMessage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteAssistantMessage"; +} +impl CompleteAssistantMessage { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::matched_stop_sequence`] to `Some(value)`, consuming and returning `self`. + pub fn with_matched_stop_sequence( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.matched_stop_sequence = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(CompleteAssistantMessage); +impl ::buffa::MessageName for CompleteAssistantMessage { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompleteAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompleteAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteAssistantMessage"; +} +impl ::buffa::Message for CompleteAssistantMessage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.finish_reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.matched_stop_sequence { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.message.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.message.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.finish_reason.to_i32(), buf); + if let Some(ref v) = self.matched_stop_sequence { + ::buffa::types::put_string_field(4u32, v, buf); + } + ::buffa::types::put_string_field(5u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.message.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.finish_reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .matched_stop_sequence + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.message = ::buffa::MessageField::none(); + self.finish_reason = ::buffa::EnumValue::from(0); + self.matched_stop_sequence = ::core::option::Option::None; + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CompleteAssistantMessage { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMPLETE_ASSISTANT_MESSAGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteAssistantMessage", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.__view.rs new file mode 100644 index 0000000000..dee4c12566 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.__view.rs @@ -0,0 +1,891 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/complete_tool_call.proto + +/// CompleteToolCall settles a call with a result, recording \[ToolCallCompleted\]. +/// +/// Write precondition Any: it races FailToolCall for the same execution, and the +/// fold resolves that by first-terminal-outcome-wins keyed on +/// tool_execution_id. A later conflicting outcome stays on the log, flagged by a +/// projection, and never changes state. +#[derive(Clone, Debug, Default)] +pub struct CompleteToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `result` + pub result: ::buffa::MessageFieldView< + super::super::__buffa::view::ToolCallResultView<'a>, + >, + /// Field 5: `turn_id` + pub turn_id: &'a str, + /// Field 6: `termination` + pub termination: ::buffa::MessageFieldView< + super::super::__buffa::view::CommandTerminationView<'a>, + >, + /// Field 7: `duration` + pub duration: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// Field 8: `observed` + pub observed: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::ResourceObservationView<'a>, + >, + /// Captured stdout and stderr, already sealed and stored as an artifact by the + /// time this command is issued. The capture is not part of the decision: a + /// decider that had to write 40 MB before it could append would be one whose + /// append latency is set by the noisiest command that ever ran. + /// + /// Field 9: `output_replay` + pub output_replay: ::buffa::MessageFieldView< + super::super::__buffa::view::CommandOutputReplayRefView<'a>, + >, + /// Set when the call is settling with a handle rather than an outcome. The + /// work it names must already be reserved in the operation ledger, so the + /// completion never points at an operation that does not exist. + /// + /// Field 10: `detached` + pub detached: ::buffa::MessageFieldView< + super::super::__buffa::view::DetachedWorkView<'a>, + >, + /// Field 11: `accessed` + pub accessed: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::ResourceAccessRecordView<'a>, + >, + /// Field 12: `failed_targets` + pub failed_targets: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::TargetOutcomeView<'a>, + >, + /// Field 13: `targets_attempted` + pub targets_attempted: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CompleteToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `result` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_result(&self) -> bool { + self.result.is_set() + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CompleteToolCallView<'a> { + type Owned = super::super::CompleteToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.result.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.result = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.termination.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.termination = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.duration.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.duration = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.output_replay.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.output_replay = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.detached.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.detached = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.targets_attempted = Some(::buffa::types::decode_uint32(&mut cur)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::ResourceObservationView, + >(), + )?; + view.observed + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::ResourceAccessRecordView, + >(), + )?; + view.accessed + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::TargetOutcomeView, + >(), + )?; + view.failed_targets + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CompleteToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + result: match self.result.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ToolCallResult, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + turn_id: self.turn_id.to_string(), + termination: match self.termination.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CommandTermination, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + duration: match self.duration.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed: self + .observed + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + output_replay: match self.output_replay.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CommandOutputReplayRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detached: match self.detached.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::DetachedWork, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + accessed: self + .accessed + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + failed_targets: self + .failed_targets + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + targets_attempted: self.targets_attempted, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CompleteToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + if self.result.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.result.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.termination.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.termination.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.observed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.output_replay.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output_replay.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.detached.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.accessed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.failed_targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.targets_attempted { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + if self.result.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.result.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.turn_id, buf); + if self.termination.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.termination.write_to(__cache, buf); + } + if self.duration.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.duration.write_to(__cache, buf); + } + for v in &self.observed { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.output_replay.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.output_replay.write_to(__cache, buf); + } + if self.detached.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached.write_to(__cache, buf); + } + for v in &self.accessed { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.failed_targets { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(v) = self.targets_attempted { + ::buffa::types::put_uint32_field(13u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CompleteToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.result.as_option() { + __map.serialize_entry("result", __v)?; + } + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.termination.as_option() { + __map.serialize_entry("termination", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.duration.as_option() { + __map.serialize_entry("duration", __v)?; + } + } + if !self.observed.is_empty() { + __map.serialize_entry("observed", &*self.observed)?; + } + { + if let ::core::option::Option::Some(__v) = self.output_replay.as_option() { + __map.serialize_entry("outputReplay", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.detached.as_option() { + __map.serialize_entry("detached", __v)?; + } + } + if !self.accessed.is_empty() { + __map.serialize_entry("accessed", &*self.accessed)?; + } + if !self.failed_targets.is_empty() { + __map.serialize_entry("failedTargets", &*self.failed_targets)?; + } + if let ::core::option::Option::Some(__v) = self.targets_attempted { + __map + .serialize_entry( + "targetsAttempted", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CompleteToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompleteToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompleteToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteToolCall"; +} +::buffa::impl_default_view_instance!(CompleteToolCallView); +::buffa::impl_view_reborrow!(CompleteToolCallView); +/** Self-contained, `'static` owned view of a `CompleteToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`CompleteToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CompleteToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CompleteToolCallOwnedView(::buffa::OwnedView>); +impl CompleteToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteToolCallOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CompleteToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CompleteToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CompleteToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CompleteToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CompleteToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `result` + #[must_use] + pub fn result( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ToolCallResultView<'_>, + > { + &self.0.reborrow().result + } + /// Field 5: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 6: `termination` + #[must_use] + pub fn termination( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CommandTerminationView<'_>, + > { + &self.0.reborrow().termination + } + /// Field 7: `duration` + #[must_use] + pub fn duration( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().duration + } + /// Field 8: `observed` + #[must_use] + pub fn observed( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::ResourceObservationView<'_>, + > { + &self.0.reborrow().observed + } + /// Captured stdout and stderr, already sealed and stored as an artifact by the + /// time this command is issued. The capture is not part of the decision: a + /// decider that had to write 40 MB before it could append would be one whose + /// append latency is set by the noisiest command that ever ran. + /// + /// Field 9: `output_replay` + #[must_use] + pub fn output_replay( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CommandOutputReplayRefView<'_>, + > { + &self.0.reborrow().output_replay + } + /// Set when the call is settling with a handle rather than an outcome. The + /// work it names must already be reserved in the operation ledger, so the + /// completion never points at an operation that does not exist. + /// + /// Field 10: `detached` + #[must_use] + pub fn detached( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().detached + } + /// Field 11: `accessed` + #[must_use] + pub fn accessed( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::ResourceAccessRecordView<'_>, + > { + &self.0.reborrow().accessed + } + /// Field 12: `failed_targets` + #[must_use] + pub fn failed_targets( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::TargetOutcomeView<'_>> { + &self.0.reborrow().failed_targets + } + /// Field 13: `targets_attempted` + #[must_use] + pub fn targets_attempted(&self) -> ::core::option::Option { + self.0.reborrow().targets_attempted + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CompleteToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CompleteToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CompleteToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CompleteToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CompleteToolCall { + type View<'a> = CompleteToolCallView<'a>; + type ViewHandle = CompleteToolCallOwnedView; +} +impl ::serde::Serialize for CompleteToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.rs new file mode 100644 index 0000000000..d259dd2dda --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.complete_tool_call.rs @@ -0,0 +1,507 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/complete_tool_call.proto + +/// CompleteToolCall settles a call with a result, recording \[ToolCallCompleted\]. +/// +/// Write precondition Any: it races FailToolCall for the same execution, and the +/// fold resolves that by first-terminal-outcome-wins keyed on +/// tool_execution_id. A later conflicting outcome stays on the log, flagged by a +/// projection, and never changes state. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CompleteToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `result` + #[serde(rename = "result")] + pub result: ::buffa::MessageField>, + /// Field 5: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 6: `termination` + #[serde( + rename = "termination", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub termination: ::buffa::MessageField< + CommandTermination, + ::buffa::Inline, + >, + /// Field 7: `duration` + #[serde( + rename = "duration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub duration: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// Field 8: `observed` + #[serde( + rename = "observed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub observed: ::buffa::alloc::vec::Vec, + /// Captured stdout and stderr, already sealed and stored as an artifact by the + /// time this command is issued. The capture is not part of the decision: a + /// decider that had to write 40 MB before it could append would be one whose + /// append latency is set by the noisiest command that ever ran. + /// + /// Field 9: `output_replay` + #[serde( + rename = "outputReplay", + alias = "output_replay", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub output_replay: ::buffa::MessageField< + CommandOutputReplayRef, + ::buffa::Inline, + >, + /// Set when the call is settling with a handle rather than an outcome. The + /// work it names must already be reserved in the operation ledger, so the + /// completion never points at an operation that does not exist. + /// + /// Field 10: `detached` + #[serde( + rename = "detached", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub detached: ::buffa::MessageField>, + /// Field 11: `accessed` + #[serde( + rename = "accessed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub accessed: ::buffa::alloc::vec::Vec, + /// Field 12: `failed_targets` + #[serde( + rename = "failedTargets", + alias = "failed_targets", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub failed_targets: ::buffa::alloc::vec::Vec, + /// Field 13: `targets_attempted` + #[serde( + rename = "targetsAttempted", + alias = "targets_attempted", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub targets_attempted: ::core::option::Option, +} +impl ::core::fmt::Debug for CompleteToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CompleteToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("result", &self.result) + .field("turn_id", &self.turn_id) + .field("termination", &self.termination) + .field("duration", &self.duration) + .field("observed", &self.observed) + .field("output_replay", &self.output_replay) + .field("detached", &self.detached) + .field("accessed", &self.accessed) + .field("failed_targets", &self.failed_targets) + .field("targets_attempted", &self.targets_attempted) + .finish() + } +} +impl CompleteToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteToolCall"; +} +impl CompleteToolCall { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::targets_attempted`] to `Some(value)`, consuming and returning `self`. + pub fn with_targets_attempted(mut self, value: u32) -> Self { + self.targets_attempted = Some(value); + self + } +} +::buffa::impl_default_instance!(CompleteToolCall); +impl ::buffa::MessageName for CompleteToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CompleteToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CompleteToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteToolCall"; +} +impl ::buffa::Message for CompleteToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + if self.result.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.result.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.termination.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.termination.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.duration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.duration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.observed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.output_replay.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output_replay.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.detached.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.accessed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.failed_targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.targets_attempted { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + if self.result.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.result.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.turn_id, buf); + if self.termination.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.termination.write_to(__cache, buf); + } + if self.duration.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.duration.write_to(__cache, buf); + } + for v in &self.observed { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if self.output_replay.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.output_replay.write_to(__cache, buf); + } + if self.detached.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached.write_to(__cache, buf); + } + for v in &self.accessed { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.failed_targets { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(v) = self.targets_attempted { + ::buffa::types::put_uint32_field(13u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.result.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.termination.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.duration.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.observed.push(elem); + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.output_replay.get_or_insert_default(), + buf, + ctx, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.detached.get_or_insert_default(), + buf, + ctx, + )?; + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.accessed.push(elem); + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.failed_targets.push(elem); + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.targets_attempted = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.result = ::buffa::MessageField::none(); + self.turn_id.clear(); + self.termination = ::buffa::MessageField::none(); + self.duration = ::buffa::MessageField::none(); + self.observed.clear(); + self.output_replay = ::buffa::MessageField::none(); + self.detached = ::buffa::MessageField::none(); + self.accessed.clear(); + self.failed_targets.clear(); + self.targets_attempted = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for CompleteToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COMPLETE_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CompleteToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.__view.rs new file mode 100644 index 0000000000..ee64c9c809 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.__view.rs @@ -0,0 +1,392 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/content_chunks.proto + +/// ContentChunks is what makes part of an artifact checkable without reading all +/// of it. +/// +/// An artifact's Digest covers the whole artifact, so it can only be checked by +/// hashing every byte. That is exactly what a range read exists to avoid: a +/// caller fetching 64 KB of a 40 MB artifact cannot afford a 40 MB verification, +/// and a caller who skips it is reading unverified bytes while holding a digest +/// that looks like it proved something. +/// +/// So the artifact is also hashed in fixed-size chunks, and the digest of that +/// ordered chunk-digest list is recorded here, on the log. A caller holding this +/// value can fetch the chunk manifest from the artifact store, check the +/// manifest against a value the store did not supply, and then check any chunk +/// it reads against the manifest. Trust flows from the event log outward, which +/// is the only direction in which it means anything: a manifest checked only +/// against the store that served it proves the store is self-consistent. +/// +/// Optional on StoredArtifact. Absent means no range of that artifact can be +/// checked, and the read contract says so rather than serving unchecked bytes +/// that look checked. +#[derive(Clone, Debug, Default)] +pub struct ContentChunksView<'a> { + /// Hash used for each chunk and for the manifest digest, for example "sha256". + /// + /// Field 1: `algorithm` + pub algorithm: &'a str, + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 2: `chunk_size_bytes` + pub chunk_size_bytes: u64, + /// Digest over the ordered chunk digests concatenated. + /// + /// The chunk count is deliberately not recorded: it follows from + /// StoredArtifact.size_bytes and chunk_size_bytes, and a second field carrying + /// a derivable fact is a second field that can disagree with the first. + /// + /// Field 3: `manifest_digest` + pub manifest_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ContentChunksView<'a> { + /**Whether required field `algorithm` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_algorithm(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `chunk_size_bytes` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_chunk_size_bytes(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `manifest_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_manifest_digest(&self) -> bool { + self.manifest_digest.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ContentChunksView<'a> { + type Owned = super::super::ContentChunks; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.algorithm = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.chunk_size_bytes = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.manifest_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.manifest_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ContentChunks { + algorithm: self.algorithm.to_string(), + chunk_size_bytes: self.chunk_size_bytes, + manifest_digest: match self.manifest_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ContentChunksView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.chunk_size_bytes) as u64; + if self.manifest_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.manifest_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.algorithm, buf); + ::buffa::types::put_uint64_field(2u32, self.chunk_size_bytes, buf); + if self.manifest_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.manifest_digest.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ContentChunksView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("algorithm", self.algorithm)?; + } + { + __map + .serialize_entry( + "chunkSizeBytes", + &::buffa::json_helpers::ProtoJson(&self.chunk_size_bytes), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.manifest_digest.as_option() { + __map.serialize_entry("manifestDigest", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ContentChunksView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ContentChunks"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ContentChunks"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ContentChunks"; +} +::buffa::impl_default_view_instance!(ContentChunksView); +::buffa::impl_view_reborrow!(ContentChunksView); +/** Self-contained, `'static` owned view of a `ContentChunks` message. + + Wraps [`::buffa::OwnedView`]`<`[`ContentChunksView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ContentChunksView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ContentChunksOwnedView(::buffa::OwnedView>); +impl ContentChunksOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentChunksOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentChunksOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ContentChunks, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ContentChunksOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ContentChunksView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ContentChunksView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ContentChunks { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Hash used for each chunk and for the manifest digest, for example "sha256". + /// + /// Field 1: `algorithm` + #[must_use] + pub fn algorithm(&self) -> &'_ str { + self.0.reborrow().algorithm + } + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 2: `chunk_size_bytes` + #[must_use] + pub fn chunk_size_bytes(&self) -> u64 { + self.0.reborrow().chunk_size_bytes + } + /// Digest over the ordered chunk digests concatenated. + /// + /// The chunk count is deliberately not recorded: it follows from + /// StoredArtifact.size_bytes and chunk_size_bytes, and a second field carrying + /// a derivable fact is a second field that can disagree with the first. + /// + /// Field 3: `manifest_digest` + #[must_use] + pub fn manifest_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().manifest_digest + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ContentChunksOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ContentChunksOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ContentChunksOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ContentChunksOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ContentChunks { + type View<'a> = ContentChunksView<'a>; + type ViewHandle = ContentChunksOwnedView; +} +impl ::serde::Serialize for ContentChunksOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.rs new file mode 100644 index 0000000000..4eccc88326 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.content_chunks.rs @@ -0,0 +1,185 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/content_chunks.proto + +/// ContentChunks is what makes part of an artifact checkable without reading all +/// of it. +/// +/// An artifact's Digest covers the whole artifact, so it can only be checked by +/// hashing every byte. That is exactly what a range read exists to avoid: a +/// caller fetching 64 KB of a 40 MB artifact cannot afford a 40 MB verification, +/// and a caller who skips it is reading unverified bytes while holding a digest +/// that looks like it proved something. +/// +/// So the artifact is also hashed in fixed-size chunks, and the digest of that +/// ordered chunk-digest list is recorded here, on the log. A caller holding this +/// value can fetch the chunk manifest from the artifact store, check the +/// manifest against a value the store did not supply, and then check any chunk +/// it reads against the manifest. Trust flows from the event log outward, which +/// is the only direction in which it means anything: a manifest checked only +/// against the store that served it proves the store is self-consistent. +/// +/// Optional on StoredArtifact. Absent means no range of that artifact can be +/// checked, and the read contract says so rather than serving unchecked bytes +/// that look checked. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ContentChunks { + /// Hash used for each chunk and for the manifest digest, for example "sha256". + /// + /// Field 1: `algorithm` + #[serde(rename = "algorithm", with = "::buffa::json_helpers::proto_string")] + pub algorithm: ::buffa::alloc::string::String, + /// Size of every chunk but the last, which holds the remainder. + /// + /// Field 2: `chunk_size_bytes` + #[serde( + rename = "chunkSizeBytes", + alias = "chunk_size_bytes", + with = "::buffa::json_helpers::uint64" + )] + pub chunk_size_bytes: u64, + /// Digest over the ordered chunk digests concatenated. + /// + /// The chunk count is deliberately not recorded: it follows from + /// StoredArtifact.size_bytes and chunk_size_bytes, and a second field carrying + /// a derivable fact is a second field that can disagree with the first. + /// + /// Field 3: `manifest_digest` + #[serde(rename = "manifestDigest", alias = "manifest_digest")] + pub manifest_digest: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for ContentChunks { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ContentChunks") + .field("algorithm", &self.algorithm) + .field("chunk_size_bytes", &self.chunk_size_bytes) + .field("manifest_digest", &self.manifest_digest) + .finish() + } +} +impl ContentChunks { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ContentChunks"; +} +::buffa::impl_default_instance!(ContentChunks); +impl ::buffa::MessageName for ContentChunks { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ContentChunks"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ContentChunks"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ContentChunks"; +} +impl ::buffa::Message for ContentChunks { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.algorithm) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.chunk_size_bytes) as u64; + if self.manifest_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.manifest_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.algorithm, buf); + ::buffa::types::put_uint64_field(2u32, self.chunk_size_bytes, buf); + if self.manifest_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.manifest_digest.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.algorithm, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.chunk_size_bytes = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.manifest_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.algorithm.clear(); + self.chunk_size_bytes = 0u64; + self.manifest_digest = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ContentChunks { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONTENT_CHUNKS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ContentChunks", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.__view.rs new file mode 100644 index 0000000000..2185fb37c5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.__view.rs @@ -0,0 +1,345 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/copy_source.proto + +/// CopySource records where a copied file came from. +/// +/// A copy recorded only as a create loses the one fact that makes it reviewable. +/// "A new file appeared at deploy/prod.yaml" and "deploy/staging.yaml was +/// duplicated to deploy/prod.yaml" are different events for a reviewer, and the +/// second is the one that raises the question worth raising. +/// +/// This is a distinct field rather than a reuse of FileChanged.previous_path, +/// even though both name an earlier location, because the two make opposite +/// claims about the source. After a rename the previous path is gone. After a +/// copy the source still exists, unchanged, and anything that treated the two the +/// same would report a file as moved that is still sitting there. +#[derive(Clone, Debug, Default)] +pub struct CopySourceView<'a> { + /// Workspace-relative path the content was copied from, in the same form as + /// FileChanged.path. + /// + /// Field 1: `path` + pub path: &'a str, + /// What the source hashed to at the moment of the copy. + /// + /// This is what makes a copy checkable later, on the same reasoning as + /// ResourceObservation: without it, a reader can see that prod.yaml came from + /// staging.yaml but cannot tell whether it came from the staging.yaml that + /// exists now or from a version since edited. Unset when the source content was + /// not hashed. + /// + /// Field 2: `source_digest` + pub source_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CopySourceView<'a> { + /**Whether required field `path` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_path(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CopySourceView<'a> { + type Owned = super::super::CopySource; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.path = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CopySource { + path: self.path.to_string(), + source_digest: match self.source_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CopySourceView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.path, buf); + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CopySourceView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("path", self.path)?; + } + { + if let ::core::option::Option::Some(__v) = self.source_digest.as_option() { + __map.serialize_entry("sourceDigest", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CopySourceView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CopySource"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CopySource"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CopySource"; +} +::buffa::impl_default_view_instance!(CopySourceView); +::buffa::impl_view_reborrow!(CopySourceView); +/** Self-contained, `'static` owned view of a `CopySource` message. + + Wraps [`::buffa::OwnedView`]`<`[`CopySourceView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CopySourceView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CopySourceOwnedView(::buffa::OwnedView>); +impl CopySourceOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CopySourceOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CopySourceOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CopySource, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CopySourceOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CopySourceView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CopySourceView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CopySource { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Workspace-relative path the content was copied from, in the same form as + /// FileChanged.path. + /// + /// Field 1: `path` + #[must_use] + pub fn path(&self) -> &'_ str { + self.0.reborrow().path + } + /// What the source hashed to at the moment of the copy. + /// + /// This is what makes a copy checkable later, on the same reasoning as + /// ResourceObservation: without it, a reader can see that prod.yaml came from + /// staging.yaml but cannot tell whether it came from the staging.yaml that + /// exists now or from a version since edited. Unset when the source content was + /// not hashed. + /// + /// Field 2: `source_digest` + #[must_use] + pub fn source_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().source_digest + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CopySourceOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CopySourceOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CopySourceOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CopySourceOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CopySource { + type View<'a> = CopySourceView<'a>; + type ViewHandle = CopySourceOwnedView; +} +impl ::serde::Serialize for CopySourceOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.rs new file mode 100644 index 0000000000..1ae8d422a6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.copy_source.rs @@ -0,0 +1,164 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/copy_source.proto + +/// CopySource records where a copied file came from. +/// +/// A copy recorded only as a create loses the one fact that makes it reviewable. +/// "A new file appeared at deploy/prod.yaml" and "deploy/staging.yaml was +/// duplicated to deploy/prod.yaml" are different events for a reviewer, and the +/// second is the one that raises the question worth raising. +/// +/// This is a distinct field rather than a reuse of FileChanged.previous_path, +/// even though both name an earlier location, because the two make opposite +/// claims about the source. After a rename the previous path is gone. After a +/// copy the source still exists, unchanged, and anything that treated the two the +/// same would report a file as moved that is still sitting there. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CopySource { + /// Workspace-relative path the content was copied from, in the same form as + /// FileChanged.path. + /// + /// Field 1: `path` + #[serde(rename = "path", with = "::buffa::json_helpers::proto_string")] + pub path: ::buffa::alloc::string::String, + /// What the source hashed to at the moment of the copy. + /// + /// This is what makes a copy checkable later, on the same reasoning as + /// ResourceObservation: without it, a reader can see that prod.yaml came from + /// staging.yaml but cannot tell whether it came from the staging.yaml that + /// exists now or from a version since edited. Unset when the source content was + /// not hashed. + /// + /// Field 2: `source_digest` + #[serde( + rename = "sourceDigest", + alias = "source_digest", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub source_digest: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for CopySource { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CopySource") + .field("path", &self.path) + .field("source_digest", &self.source_digest) + .finish() + } +} +impl CopySource { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CopySource"; +} +::buffa::impl_default_instance!(CopySource); +impl ::buffa::MessageName for CopySource { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CopySource"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CopySource"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CopySource"; +} +impl ::buffa::Message for CopySource { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.path, buf); + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.path, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.path.clear(); + self.source_digest = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CopySource { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __COPY_SOURCE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CopySource", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.__view.rs new file mode 100644 index 0000000000..b2bbbab1e9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.__view.rs @@ -0,0 +1,582 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/create_child_session.proto + +/// CreateChildSession is the delegation saga's second step: it opens the +/// delegated child's stream, recording \[SessionStarted, ParentLinked\] as one +/// batch so a child can never exist without its lineage. +/// +/// Write precondition NoStream on the child. parent_dispatched_at and +/// cascade_policy are copied verbatim from the parent's DelegationDispatched, so +/// a redelivered saga step reproduces the same link (ADR#0035 facet 6). +#[derive(Clone, Debug, Default)] +pub struct CreateChildSessionView<'a> { + /// The child session's own id. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_plan` + pub execution_plan: ::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'a>, + >, + /// Field 3: `workspace` + pub workspace: ::buffa::MessageFieldView< + super::super::__buffa::view::WorkspaceRefView<'a>, + >, + /// Field 4: `parent_session_id` + pub parent_session_id: &'a str, + /// The parent's own ordinal of the DelegationDispatched being followed. + /// + /// Field 5: `parent_dispatched_at` + pub parent_dispatched_at: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 6: `cascade_policy` + pub cascade_policy: ::buffa::EnumValue, + /// The parent-side ledger operation this dispatch reserved. + /// + /// Field 7: `operation_id` + pub operation_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CreateChildSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_plan` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_plan(&self) -> bool { + self.execution_plan.is_set() + } + /**Whether required field `workspace` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace(&self) -> bool { + self.workspace.is_set() + } + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `parent_dispatched_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_dispatched_at(&self) -> bool { + self.parent_dispatched_at.is_set() + } + /**Whether required field `cascade_policy` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_cascade_policy(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for CreateChildSessionView<'a> { + type Owned = super::super::CreateChildSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.execution_plan.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.execution_plan = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.workspace.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.workspace = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.parent_dispatched_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.parent_dispatched_at = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CreateChildSession { + session_id: self.session_id.to_string(), + execution_plan: match self.execution_plan.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StoredSessionExecutionPlan, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + workspace: match self.workspace.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::WorkspaceRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + parent_session_id: self.parent_session_id.to_string(), + parent_dispatched_at: match self.parent_dispatched_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + cascade_policy: self.cascade_policy, + operation_id: self.operation_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CreateChildSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.parent_session_id, buf); + if self.parent_dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_dispatched_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.cascade_policy.to_i32(), buf); + ::buffa::types::put_string_field(7u32, &self.operation_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CreateChildSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.execution_plan.as_option() { + __map.serialize_entry("executionPlan", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.workspace.as_option() { + __map.serialize_entry("workspace", __v)?; + } + } + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .parent_dispatched_at + .as_option() + { + __map.serialize_entry("parentDispatchedAt", __v)?; + } + } + { + __map.serialize_entry("cascadePolicy", &self.cascade_policy)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CreateChildSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CreateChildSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CreateChildSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateChildSession"; +} +::buffa::impl_default_view_instance!(CreateChildSessionView); +::buffa::impl_view_reborrow!(CreateChildSessionView); +/** Self-contained, `'static` owned view of a `CreateChildSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`CreateChildSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CreateChildSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CreateChildSessionOwnedView( + ::buffa::OwnedView>, +); +impl CreateChildSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateChildSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateChildSessionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CreateChildSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateChildSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CreateChildSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CreateChildSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CreateChildSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The child session's own id. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_plan` + #[must_use] + pub fn execution_plan( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'_>, + > { + &self.0.reborrow().execution_plan + } + /// Field 3: `workspace` + #[must_use] + pub fn workspace( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().workspace + } + /// Field 4: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// The parent's own ordinal of the DelegationDispatched being followed. + /// + /// Field 5: `parent_dispatched_at` + #[must_use] + pub fn parent_dispatched_at( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().parent_dispatched_at + } + /// Field 6: `cascade_policy` + #[must_use] + pub fn cascade_policy(&self) -> ::buffa::EnumValue { + self.0.reborrow().cascade_policy + } + /// The parent-side ledger operation this dispatch reserved. + /// + /// Field 7: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CreateChildSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CreateChildSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CreateChildSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CreateChildSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CreateChildSession { + type View<'a> = CreateChildSessionView<'a>; + type ViewHandle = CreateChildSessionOwnedView; +} +impl ::serde::Serialize for CreateChildSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.rs new file mode 100644 index 0000000000..ca1ca2fca8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_child_session.rs @@ -0,0 +1,284 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/create_child_session.proto + +/// CreateChildSession is the delegation saga's second step: it opens the +/// delegated child's stream, recording \[SessionStarted, ParentLinked\] as one +/// batch so a child can never exist without its lineage. +/// +/// Write precondition NoStream on the child. parent_dispatched_at and +/// cascade_policy are copied verbatim from the parent's DelegationDispatched, so +/// a redelivered saga step reproduces the same link (ADR#0035 facet 6). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateChildSession { + /// The child session's own id. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_plan` + #[serde(rename = "executionPlan", alias = "execution_plan")] + pub execution_plan: ::buffa::MessageField< + StoredSessionExecutionPlan, + ::buffa::Inline, + >, + /// Field 3: `workspace` + #[serde(rename = "workspace")] + pub workspace: ::buffa::MessageField>, + /// Field 4: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// The parent's own ordinal of the DelegationDispatched being followed. + /// + /// Field 5: `parent_dispatched_at` + #[serde(rename = "parentDispatchedAt", alias = "parent_dispatched_at")] + pub parent_dispatched_at: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 6: `cascade_policy` + #[serde( + rename = "cascadePolicy", + alias = "cascade_policy", + with = "::buffa::json_helpers::proto_enum" + )] + pub cascade_policy: ::buffa::EnumValue, + /// The parent-side ledger operation this dispatch reserved. + /// + /// Field 7: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for CreateChildSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateChildSession") + .field("session_id", &self.session_id) + .field("execution_plan", &self.execution_plan) + .field("workspace", &self.workspace) + .field("parent_session_id", &self.parent_session_id) + .field("parent_dispatched_at", &self.parent_dispatched_at) + .field("cascade_policy", &self.cascade_policy) + .field("operation_id", &self.operation_id) + .finish() + } +} +impl CreateChildSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateChildSession"; +} +::buffa::impl_default_instance!(CreateChildSession); +impl ::buffa::MessageName for CreateChildSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CreateChildSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CreateChildSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateChildSession"; +} +impl ::buffa::Message for CreateChildSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_dispatched_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_dispatched_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.parent_session_id, buf); + if self.parent_dispatched_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_dispatched_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.cascade_policy.to_i32(), buf); + ::buffa::types::put_string_field(7u32, &self.operation_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.execution_plan.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.workspace.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.parent_dispatched_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_plan = ::buffa::MessageField::none(); + self.workspace = ::buffa::MessageField::none(); + self.parent_session_id.clear(); + self.parent_dispatched_at = ::buffa::MessageField::none(); + self.cascade_policy = ::buffa::EnumValue::from(0); + self.operation_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateChildSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_CHILD_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateChildSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.__view.rs new file mode 100644 index 0000000000..0837565ead --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.__view.rs @@ -0,0 +1,398 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/create_session.proto + +/// CreateSession opens a session stream, recording \[SessionStarted\]. +/// +/// Write precondition NoStream: creation is atomic and exactly-once, so a +/// redelivered create observes the stream already exists rather than forking a +/// second history (ADR#0035 facet 2). The execution plan is immutable for the +/// session's life; every later attempt, checkpoint, and compaction is bound to +/// its digest. +#[derive(Clone, Debug, Default)] +pub struct CreateSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_plan` + pub execution_plan: ::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'a>, + >, + /// Field 3: `workspace` + pub workspace: ::buffa::MessageFieldView< + super::super::__buffa::view::WorkspaceRefView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> CreateSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_plan` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_plan(&self) -> bool { + self.execution_plan.is_set() + } + /**Whether required field `workspace` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace(&self) -> bool { + self.workspace.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for CreateSessionView<'a> { + type Owned = super::super::CreateSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.execution_plan.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.execution_plan = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.workspace.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.workspace = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::CreateSession { + session_id: self.session_id.to_string(), + execution_plan: match self.execution_plan.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StoredSessionExecutionPlan, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + workspace: match self.workspace.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::WorkspaceRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for CreateSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for CreateSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.execution_plan.as_option() { + __map.serialize_entry("executionPlan", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.workspace.as_option() { + __map.serialize_entry("workspace", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for CreateSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CreateSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CreateSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateSession"; +} +::buffa::impl_default_view_instance!(CreateSessionView); +::buffa::impl_view_reborrow!(CreateSessionView); +/** Self-contained, `'static` owned view of a `CreateSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`CreateSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`CreateSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct CreateSessionOwnedView(::buffa::OwnedView>); +impl CreateSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::CreateSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + CreateSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`CreateSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &CreateSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::CreateSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_plan` + #[must_use] + pub fn execution_plan( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'_>, + > { + &self.0.reborrow().execution_plan + } + /// Field 3: `workspace` + #[must_use] + pub fn workspace( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().workspace + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for CreateSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + CreateSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: CreateSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for CreateSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::CreateSession { + type View<'a> = CreateSessionView<'a>; + type ViewHandle = CreateSessionOwnedView; +} +impl ::serde::Serialize for CreateSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.rs new file mode 100644 index 0000000000..ce3db91f31 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.create_session.rs @@ -0,0 +1,183 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/create_session.proto + +/// CreateSession opens a session stream, recording \[SessionStarted\]. +/// +/// Write precondition NoStream: creation is atomic and exactly-once, so a +/// redelivered create observes the stream already exists rather than forking a +/// second history (ADR#0035 facet 2). The execution plan is immutable for the +/// session's life; every later attempt, checkpoint, and compaction is bound to +/// its digest. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_plan` + #[serde(rename = "executionPlan", alias = "execution_plan")] + pub execution_plan: ::buffa::MessageField< + StoredSessionExecutionPlan, + ::buffa::Inline, + >, + /// Field 3: `workspace` + #[serde(rename = "workspace")] + pub workspace: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for CreateSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateSession") + .field("session_id", &self.session_id) + .field("execution_plan", &self.execution_plan) + .field("workspace", &self.workspace) + .finish() + } +} +impl CreateSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateSession"; +} +::buffa::impl_default_instance!(CreateSession); +impl ::buffa::MessageName for CreateSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "CreateSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.CreateSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateSession"; +} +impl ::buffa::Message for CreateSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.execution_plan.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.workspace.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_plan = ::buffa::MessageField::none(); + self.workspace = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.CreateSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.__view.rs new file mode 100644 index 0000000000..0104dac352 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.__view.rs @@ -0,0 +1,389 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/deny_tool_call.proto + +/// DenyToolCall records a human decision to refuse a call, recording +/// \[ToolCallDenied\]. Denial is terminal for the call: it never starts. +/// +/// Write precondition At: mutually exclusive with approve. +#[derive(Clone, Debug, Default)] +pub struct DenyToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `denied_by` + pub denied_by: &'a str, + /// Field 5: `reason` + pub reason: ::core::option::Option<&'a str>, + /// Field 6: `turn_id` + pub turn_id: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DenyToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `denied_by` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_denied_by(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DenyToolCallView<'a> { + type Owned = super::super::DenyToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.denied_by = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DenyToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + denied_by: self.denied_by.to_string(), + reason: self.reason.map(|s| s.to_string()), + turn_id: self.turn_id.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DenyToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.denied_by) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.turn_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.denied_by, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(5u32, v, buf); + } + if let Some(ref v) = self.turn_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DenyToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("deniedBy", self.denied_by)?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + if let ::core::option::Option::Some(__v) = self.turn_id { + __map.serialize_entry("turnId", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DenyToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DenyToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DenyToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DenyToolCall"; +} +::buffa::impl_default_view_instance!(DenyToolCallView); +::buffa::impl_view_reborrow!(DenyToolCallView); +/** Self-contained, `'static` owned view of a `DenyToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`DenyToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DenyToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DenyToolCallOwnedView(::buffa::OwnedView>); +impl DenyToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DenyToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DenyToolCallOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DenyToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DenyToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DenyToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DenyToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DenyToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `denied_by` + #[must_use] + pub fn denied_by(&self) -> &'_ str { + self.0.reborrow().denied_by + } + /// Field 5: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } + /// Field 6: `turn_id` + #[must_use] + pub fn turn_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DenyToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DenyToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DenyToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DenyToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DenyToolCall { + type View<'a> = DenyToolCallView<'a>; + type ViewHandle = DenyToolCallOwnedView; +} +impl ::serde::Serialize for DenyToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.rs new file mode 100644 index 0000000000..40661b2b96 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.deny_tool_call.rs @@ -0,0 +1,236 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/deny_tool_call.proto + +/// DenyToolCall records a human decision to refuse a call, recording +/// \[ToolCallDenied\]. Denial is terminal for the call: it never starts. +/// +/// Write precondition At: mutually exclusive with approve. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DenyToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `denied_by` + #[serde( + rename = "deniedBy", + alias = "denied_by", + with = "::buffa::json_helpers::proto_string" + )] + pub denied_by: ::buffa::alloc::string::String, + /// Field 5: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 6: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub turn_id: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for DenyToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DenyToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("denied_by", &self.denied_by) + .field("reason", &self.reason) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl DenyToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DenyToolCall"; +} +impl DenyToolCall { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::turn_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_turn_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.turn_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DenyToolCall); +impl ::buffa::MessageName for DenyToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DenyToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DenyToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DenyToolCall"; +} +impl ::buffa::Message for DenyToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.denied_by) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.turn_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.denied_by, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(5u32, v, buf); + } + if let Some(ref v) = self.turn_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.denied_by, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.turn_id.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.denied_by.clear(); + self.reason = ::core::option::Option::None; + self.turn_id = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DenyToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DENY_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DenyToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.__view.rs new file mode 100644 index 0000000000..c1f9b15796 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.__view.rs @@ -0,0 +1,345 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detach_delegation.proto + +/// DetachDelegation releases a child from its parent, run against the parent +/// side, recording \[DelegationDetached\]. After it, the parent's terminal state +/// no longer cascades to that child. +/// +/// Write precondition At: one detach per detach_operation_id. The child-side +/// half of the same intent is DetachParent. +#[derive(Clone, Debug, Default)] +pub struct DetachDelegationView<'a> { + /// The parent session. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `child_session_id` + pub child_session_id: &'a str, + /// Field 3: `detach_operation_id` + pub detach_operation_id: &'a str, + /// Field 4: `reason` + pub reason: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DetachDelegationView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `child_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_child_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `detach_operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_detach_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DetachDelegationView<'a> { + type Owned = super::super::DetachDelegation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.child_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detach_operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DetachDelegation { + session_id: self.session_id.to_string(), + child_session_id: self.child_session_id.to_string(), + detach_operation_id: self.detach_operation_id.to_string(), + reason: self.reason.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DetachDelegationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.child_session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.detach_operation_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.child_session_id, buf); + ::buffa::types::put_string_field(3u32, &self.detach_operation_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DetachDelegationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("childSessionId", self.child_session_id)?; + } + { + __map.serialize_entry("detachOperationId", self.detach_operation_id)?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DetachDelegationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachDelegation"; +} +::buffa::impl_default_view_instance!(DetachDelegationView); +::buffa::impl_view_reborrow!(DetachDelegationView); +/** Self-contained, `'static` owned view of a `DetachDelegation` message. + + Wraps [`::buffa::OwnedView`]`<`[`DetachDelegationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DetachDelegationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DetachDelegationOwnedView(::buffa::OwnedView>); +impl DetachDelegationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachDelegationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachDelegationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DetachDelegation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachDelegationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DetachDelegationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DetachDelegationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DetachDelegation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The parent session. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `child_session_id` + #[must_use] + pub fn child_session_id(&self) -> &'_ str { + self.0.reborrow().child_session_id + } + /// Field 3: `detach_operation_id` + #[must_use] + pub fn detach_operation_id(&self) -> &'_ str { + self.0.reborrow().detach_operation_id + } + /// Field 4: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DetachDelegationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DetachDelegationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DetachDelegationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DetachDelegationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DetachDelegation { + type View<'a> = DetachDelegationView<'a>; + type ViewHandle = DetachDelegationOwnedView; +} +impl ::serde::Serialize for DetachDelegationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.rs new file mode 100644 index 0000000000..15b39234dc --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_delegation.rs @@ -0,0 +1,188 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detach_delegation.proto + +/// DetachDelegation releases a child from its parent, run against the parent +/// side, recording \[DelegationDetached\]. After it, the parent's terminal state +/// no longer cascades to that child. +/// +/// Write precondition At: one detach per detach_operation_id. The child-side +/// half of the same intent is DetachParent. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DetachDelegation { + /// The parent session. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `child_session_id` + #[serde( + rename = "childSessionId", + alias = "child_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub child_session_id: ::buffa::alloc::string::String, + /// Field 3: `detach_operation_id` + #[serde( + rename = "detachOperationId", + alias = "detach_operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub detach_operation_id: ::buffa::alloc::string::String, + /// Field 4: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for DetachDelegation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DetachDelegation") + .field("session_id", &self.session_id) + .field("child_session_id", &self.child_session_id) + .field("detach_operation_id", &self.detach_operation_id) + .field("reason", &self.reason) + .finish() + } +} +impl DetachDelegation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachDelegation"; +} +impl DetachDelegation { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DetachDelegation); +impl ::buffa::MessageName for DetachDelegation { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachDelegation"; +} +impl ::buffa::Message for DetachDelegation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.child_session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.detach_operation_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.child_session_id, buf); + ::buffa::types::put_string_field(3u32, &self.detach_operation_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.child_session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.detach_operation_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.child_session_id.clear(); + self.detach_operation_id.clear(); + self.reason = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DetachDelegation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DETACH_DELEGATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachDelegation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.__view.rs new file mode 100644 index 0000000000..b9fb4e0650 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.__view.rs @@ -0,0 +1,320 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detach_parent.proto + +/// DetachParent releases a child from its parent, run against the child side, +/// recording \[ParentDetached\]. It is the repair half of DetachDelegation: the +/// two sides carry the same detach_operation_id, so a saga interrupted between +/// them converges rather than leaving one side linked. +/// +/// Write precondition At: one detach per detach_operation_id. +#[derive(Clone, Debug, Default)] +pub struct DetachParentView<'a> { + /// The child session. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `parent_session_id` + pub parent_session_id: &'a str, + /// Field 3: `detach_operation_id` + pub detach_operation_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DetachParentView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `detach_operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_detach_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DetachParentView<'a> { + type Owned = super::super::DetachParent; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detach_operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DetachParent { + session_id: self.session_id.to_string(), + parent_session_id: self.parent_session_id.to_string(), + detach_operation_id: self.detach_operation_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DetachParentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.detach_operation_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + ::buffa::types::put_string_field(3u32, &self.detach_operation_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DetachParentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + __map.serialize_entry("detachOperationId", self.detach_operation_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DetachParentView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachParent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachParent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachParent"; +} +::buffa::impl_default_view_instance!(DetachParentView); +::buffa::impl_view_reborrow!(DetachParentView); +/** Self-contained, `'static` owned view of a `DetachParent` message. + + Wraps [`::buffa::OwnedView`]`<`[`DetachParentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DetachParentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DetachParentOwnedView(::buffa::OwnedView>); +impl DetachParentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachParentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachParentOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DetachParent, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachParentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DetachParentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DetachParentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DetachParent { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The child session. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// Field 3: `detach_operation_id` + #[must_use] + pub fn detach_operation_id(&self) -> &'_ str { + self.0.reborrow().detach_operation_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DetachParentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DetachParentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DetachParentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DetachParentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DetachParent { + type View<'a> = DetachParentView<'a>; + type ViewHandle = DetachParentOwnedView; +} +impl ::serde::Serialize for DetachParentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.rs new file mode 100644 index 0000000000..76b5273a68 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detach_parent.rs @@ -0,0 +1,156 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detach_parent.proto + +/// DetachParent releases a child from its parent, run against the child side, +/// recording \[ParentDetached\]. It is the repair half of DetachDelegation: the +/// two sides carry the same detach_operation_id, so a saga interrupted between +/// them converges rather than leaving one side linked. +/// +/// Write precondition At: one detach per detach_operation_id. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DetachParent { + /// The child session. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// Field 3: `detach_operation_id` + #[serde( + rename = "detachOperationId", + alias = "detach_operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub detach_operation_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for DetachParent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DetachParent") + .field("session_id", &self.session_id) + .field("parent_session_id", &self.parent_session_id) + .field("detach_operation_id", &self.detach_operation_id) + .finish() + } +} +impl DetachParent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachParent"; +} +::buffa::impl_default_instance!(DetachParent); +impl ::buffa::MessageName for DetachParent { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachParent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachParent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachParent"; +} +impl ::buffa::Message for DetachParent { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.detach_operation_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + ::buffa::types::put_string_field(3u32, &self.detach_operation_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.detach_operation_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.parent_session_id.clear(); + self.detach_operation_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DetachParent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DETACH_PARENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachParent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.__view.rs new file mode 100644 index 0000000000..20fbd71d6b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.__view.rs @@ -0,0 +1,863 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detached_work.proto + +/// DetachedWork records that a tool call returned a handle while its work +/// continued outside the turn. +/// +/// A development server is the ordinary case: the tool starts it, returns a URL, +/// and the turn ends while the process keeps running and keeps producing output. +/// Without this the completion is a lie of omission. `ToolCallCompleted` means +/// the call finished, a reader folds it as done, and a process nobody is +/// tracking outlives the session that started it. +/// +/// It is deliberately not a compound background-turn record. Everything durable +/// about the work already has a home: `operation_id` joins the operation ledger, +/// the eventual result arrives as `OperationOutcomeRecorded`, cancellation is +/// `OperationCancellationRequested`, and captured output is a +/// `CommandOutputReplayRef` sealed when the process ends. What was missing is +/// only the fact that the turn was released first, plus the two policies nobody +/// could otherwise infer. +#[derive(Clone, Debug, Default)] +pub struct DetachedWorkView<'a> { + /// The reserved operation this work continues under, joining to + /// OperationReserved and the eventual OperationOutcomeRecorded. + /// + /// Required here, unlike ToolCallRequested.operation_id, which is empty for a + /// call that reserves nothing. Work that outlives its turn has to be + /// addressable to be cancellable, and an unaddressable detached process is the + /// thing this message exists to prevent. + /// + /// Field 1: `operation_id` + pub operation_id: &'a str, + /// Wall-clock instant the turn was released, a real external occurrence + /// distinct from envelope append time (D10). + /// + /// Field 2: `detached_at` + pub detached_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// What happens to this work when the session reaches a terminal state. + /// + /// Field 3: `terminal_ownership` + pub terminal_ownership: ::buffa::EnumValue, + /// How long the work may go unsupervised before a runner is presumed lost. + /// + /// Field 4: `supervision` + pub supervision: ::buffa::MessageFieldView< + super::super::__buffa::view::SupervisionPolicyView<'a>, + >, + /// Where the caller can reach what was started: a URL, a socket path, a + /// container id. Empty when the work exposes nothing addressable. + /// + /// Must be credential-free, the same prohibition ExternalArtifact.source_url + /// carries (D7). A detached development server's URL is the field most likely + /// to arrive with a session token stapled to it. + /// + /// Field 5: `endpoint` + pub endpoint: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DetachedWorkView<'a> { + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `detached_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_detached_at(&self) -> bool { + self.detached_at.is_set() + } + /**Whether required field `terminal_ownership` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_terminal_ownership(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `supervision` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_supervision(&self) -> bool { + self.supervision.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for DetachedWorkView<'a> { + type Owned = super::super::DetachedWork; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.detached_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.detached_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.terminal_ownership = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.supervision.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.supervision = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.endpoint = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DetachedWork { + operation_id: self.operation_id.to_string(), + detached_at: match self.detached_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + terminal_ownership: self.terminal_ownership, + supervision: match self.supervision.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SupervisionPolicy, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + endpoint: self.endpoint.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DetachedWorkView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.detached_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.terminal_ownership.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.supervision.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.supervision.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.endpoint { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + if self.detached_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.terminal_ownership.to_i32(), buf); + if self.supervision.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.supervision.write_to(__cache, buf); + } + if let Some(ref v) = self.endpoint { + ::buffa::types::put_string_field(5u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DetachedWorkView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.detached_at.as_option() { + __map.serialize_entry("detachedAt", __v)?; + } + } + { + __map.serialize_entry("terminalOwnership", &self.terminal_ownership)?; + } + { + if let ::core::option::Option::Some(__v) = self.supervision.as_option() { + __map.serialize_entry("supervision", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.endpoint { + __map.serialize_entry("endpoint", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DetachedWorkView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachedWork"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachedWork"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachedWork"; +} +::buffa::impl_default_view_instance!(DetachedWorkView); +::buffa::impl_view_reborrow!(DetachedWorkView); +/** Self-contained, `'static` owned view of a `DetachedWork` message. + + Wraps [`::buffa::OwnedView`]`<`[`DetachedWorkView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DetachedWorkView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DetachedWorkOwnedView(::buffa::OwnedView>); +impl DetachedWorkOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachedWorkOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachedWorkOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DetachedWork, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DetachedWorkOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DetachedWorkView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DetachedWorkView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DetachedWork { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The reserved operation this work continues under, joining to + /// OperationReserved and the eventual OperationOutcomeRecorded. + /// + /// Required here, unlike ToolCallRequested.operation_id, which is empty for a + /// call that reserves nothing. Work that outlives its turn has to be + /// addressable to be cancellable, and an unaddressable detached process is the + /// thing this message exists to prevent. + /// + /// Field 1: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Wall-clock instant the turn was released, a real external occurrence + /// distinct from envelope append time (D10). + /// + /// Field 2: `detached_at` + #[must_use] + pub fn detached_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().detached_at + } + /// What happens to this work when the session reaches a terminal state. + /// + /// Field 3: `terminal_ownership` + #[must_use] + pub fn terminal_ownership( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().terminal_ownership + } + /// How long the work may go unsupervised before a runner is presumed lost. + /// + /// Field 4: `supervision` + #[must_use] + pub fn supervision( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SupervisionPolicyView<'_>, + > { + &self.0.reborrow().supervision + } + /// Where the caller can reach what was started: a URL, a socket path, a + /// container id. Empty when the work exposes nothing addressable. + /// + /// Must be credential-free, the same prohibition ExternalArtifact.source_url + /// carries (D7). A detached development server's URL is the field most likely + /// to arrive with a session token stapled to it. + /// + /// Field 5: `endpoint` + #[must_use] + pub fn endpoint(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().endpoint + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DetachedWorkOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DetachedWorkOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DetachedWorkOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DetachedWorkOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DetachedWork { + type View<'a> = DetachedWorkView<'a>; + type ViewHandle = DetachedWorkOwnedView; +} +impl ::serde::Serialize for DetachedWorkOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SupervisionPolicy is how a lost runner becomes detectable. +/// +/// It records the policy and never the heartbeat. A renewal per interval would +/// be an append per interval, into a log that is never truncated +/// (ADR#0035 facet 7), and long-lived detached work is precisely the case that +/// generates the most of them. That is the same reason FX-23 keeps a downstream +/// consumer's checkpoint flood out of Session streams: liveness is live state, +/// and live state belongs in the runner registry that a projection reads, not in +/// the history that outlives it. +/// +/// What the log holds is the number a reconciler needs afterwards. Given +/// `max_unsupervised` and the last observed supervision, whether a runner is +/// lost is a question anyone can answer later without having watched. +#[derive(Clone, Debug, Default)] +pub struct SupervisionPolicyView<'a> { + /// How long the work may run without an observed supervisor before it is + /// presumed abandoned and becomes a reconciliation candidate. + /// + /// Field 1: `max_unsupervised` + pub max_unsupervised: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// Identity of the runner that held the work at detach time. Opaque, and + /// recorded so a reconciler can tell work whose runner is gone from work whose + /// runner is merely quiet. + /// + /// Field 2: `runner_id` + pub runner_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SupervisionPolicyView<'a> { + /**Whether required field `max_unsupervised` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_max_unsupervised(&self) -> bool { + self.max_unsupervised.is_set() + } + /**Whether required field `runner_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_runner_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SupervisionPolicyView<'a> { + type Owned = super::super::SupervisionPolicy; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.max_unsupervised.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.max_unsupervised = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.runner_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SupervisionPolicy { + max_unsupervised: match self.max_unsupervised.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + runner_id: self.runner_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SupervisionPolicyView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.max_unsupervised.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_unsupervised.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.runner_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.max_unsupervised.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_unsupervised.write_to(__cache, buf); + } + ::buffa::types::put_string_field(2u32, &self.runner_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SupervisionPolicyView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.max_unsupervised.as_option() + { + __map.serialize_entry("maxUnsupervised", __v)?; + } + } + { + __map.serialize_entry("runnerId", self.runner_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SupervisionPolicyView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "SupervisionPolicy"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.SupervisionPolicy"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SupervisionPolicy"; +} +::buffa::impl_default_view_instance!(SupervisionPolicyView); +::buffa::impl_view_reborrow!(SupervisionPolicyView); +/** Self-contained, `'static` owned view of a `SupervisionPolicy` message. + + Wraps [`::buffa::OwnedView`]`<`[`SupervisionPolicyView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SupervisionPolicyView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SupervisionPolicyOwnedView( + ::buffa::OwnedView>, +); +impl SupervisionPolicyOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SupervisionPolicyOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SupervisionPolicyOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SupervisionPolicy, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SupervisionPolicyOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SupervisionPolicyView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SupervisionPolicyView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SupervisionPolicy { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// How long the work may run without an observed supervisor before it is + /// presumed abandoned and becomes a reconciliation candidate. + /// + /// Field 1: `max_unsupervised` + #[must_use] + pub fn max_unsupervised( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().max_unsupervised + } + /// Identity of the runner that held the work at detach time. Opaque, and + /// recorded so a reconciler can tell work whose runner is gone from work whose + /// runner is merely quiet. + /// + /// Field 2: `runner_id` + #[must_use] + pub fn runner_id(&self) -> &'_ str { + self.0.reborrow().runner_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SupervisionPolicyOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SupervisionPolicyOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SupervisionPolicyOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SupervisionPolicyOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SupervisionPolicy { + type View<'a> = SupervisionPolicyView<'a>; + type ViewHandle = SupervisionPolicyOwnedView; +} +impl ::serde::Serialize for SupervisionPolicyOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.rs new file mode 100644 index 0000000000..4349fae6fe --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.detached_work.rs @@ -0,0 +1,616 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/detached_work.proto + +/// TerminalOwnership is what becomes of detached work when its session ends. +/// +/// The zero value cancels, because the two failure modes are not symmetric. +/// Cancelling work that should have survived is visible: something the user +/// wanted stopped, and they find out. Leaving work running that should have +/// stopped is invisible, and it is the orphan problem in +/// `doctor/v1alpha1/orphan.proto` with a process attached instead of a byte +/// range. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TerminalOwnership { + /// Unknown policy. Treat as CANCEL_ON_TERMINAL. + TERMINAL_OWNERSHIP_UNSPECIFIED = 0i32, + /// Cancel the operation when the session reaches a terminal state. + TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL = 1i32, + /// Let the work continue past the session's terminal state. + /// + /// The session still owns the record of it. A terminal session with surviving + /// detached work is exactly the case `SessionView.has_unreconciled_work` + /// exists for: terminal is not the same as complete, and a reader that treats + /// them as the same will report a session as finished while its work is still + /// running. + TERMINAL_OWNERSHIP_SURVIVE_TERMINAL = 2i32, +} +impl TerminalOwnership { + ///Idiomatic alias for [`Self::TERMINAL_OWNERSHIP_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TERMINAL_OWNERSHIP_UNSPECIFIED; + ///Idiomatic alias for [`Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const CancelOnTerminal: Self = Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL; + ///Idiomatic alias for [`Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SurviveTerminal: Self = Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL; +} +impl ::core::default::Default for TerminalOwnership { + fn default() -> Self { + Self::TERMINAL_OWNERSHIP_UNSPECIFIED + } +} +impl ::serde::Serialize for TerminalOwnership { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TerminalOwnership { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TerminalOwnership; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(TerminalOwnership) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TerminalOwnership { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TerminalOwnership { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL) + } + 2i32 => { + ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TERMINAL_OWNERSHIP_UNSPECIFIED => "TERMINAL_OWNERSHIP_UNSPECIFIED", + Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL => { + "TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL" + } + Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL => { + "TERMINAL_OWNERSHIP_SURVIVE_TERMINAL" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TERMINAL_OWNERSHIP_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_UNSPECIFIED) + } + "TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL" => { + ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL) + } + "TERMINAL_OWNERSHIP_SURVIVE_TERMINAL" => { + ::core::option::Option::Some(Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TERMINAL_OWNERSHIP_UNSPECIFIED, + Self::TERMINAL_OWNERSHIP_CANCEL_ON_TERMINAL, + Self::TERMINAL_OWNERSHIP_SURVIVE_TERMINAL, + ] + } +} +/// DetachedWork records that a tool call returned a handle while its work +/// continued outside the turn. +/// +/// A development server is the ordinary case: the tool starts it, returns a URL, +/// and the turn ends while the process keeps running and keeps producing output. +/// Without this the completion is a lie of omission. `ToolCallCompleted` means +/// the call finished, a reader folds it as done, and a process nobody is +/// tracking outlives the session that started it. +/// +/// It is deliberately not a compound background-turn record. Everything durable +/// about the work already has a home: `operation_id` joins the operation ledger, +/// the eventual result arrives as `OperationOutcomeRecorded`, cancellation is +/// `OperationCancellationRequested`, and captured output is a +/// `CommandOutputReplayRef` sealed when the process ends. What was missing is +/// only the fact that the turn was released first, plus the two policies nobody +/// could otherwise infer. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DetachedWork { + /// The reserved operation this work continues under, joining to + /// OperationReserved and the eventual OperationOutcomeRecorded. + /// + /// Required here, unlike ToolCallRequested.operation_id, which is empty for a + /// call that reserves nothing. Work that outlives its turn has to be + /// addressable to be cancellable, and an unaddressable detached process is the + /// thing this message exists to prevent. + /// + /// Field 1: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Wall-clock instant the turn was released, a real external occurrence + /// distinct from envelope append time (D10). + /// + /// Field 2: `detached_at` + #[serde(rename = "detachedAt", alias = "detached_at")] + pub detached_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// What happens to this work when the session reaches a terminal state. + /// + /// Field 3: `terminal_ownership` + #[serde( + rename = "terminalOwnership", + alias = "terminal_ownership", + with = "::buffa::json_helpers::proto_enum" + )] + pub terminal_ownership: ::buffa::EnumValue, + /// How long the work may go unsupervised before a runner is presumed lost. + /// + /// Field 4: `supervision` + #[serde(rename = "supervision")] + pub supervision: ::buffa::MessageField< + SupervisionPolicy, + ::buffa::Inline, + >, + /// Where the caller can reach what was started: a URL, a socket path, a + /// container id. Empty when the work exposes nothing addressable. + /// + /// Must be credential-free, the same prohibition ExternalArtifact.source_url + /// carries (D7). A detached development server's URL is the field most likely + /// to arrive with a session token stapled to it. + /// + /// Field 5: `endpoint` + #[serde( + rename = "endpoint", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub endpoint: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for DetachedWork { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DetachedWork") + .field("operation_id", &self.operation_id) + .field("detached_at", &self.detached_at) + .field("terminal_ownership", &self.terminal_ownership) + .field("supervision", &self.supervision) + .field("endpoint", &self.endpoint) + .finish() + } +} +impl DetachedWork { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachedWork"; +} +impl DetachedWork { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::endpoint`] to `Some(value)`, consuming and returning `self`. + pub fn with_endpoint( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.endpoint = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(DetachedWork); +impl ::buffa::MessageName for DetachedWork { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DetachedWork"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DetachedWork"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachedWork"; +} +impl ::buffa::Message for DetachedWork { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.detached_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.terminal_ownership.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.supervision.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.supervision.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.endpoint { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.operation_id, buf); + if self.detached_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.terminal_ownership.to_i32(), buf); + if self.supervision.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.supervision.write_to(__cache, buf); + } + if let Some(ref v) = self.endpoint { + ::buffa::types::put_string_field(5u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.detached_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.terminal_ownership = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.supervision.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .endpoint + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.operation_id.clear(); + self.detached_at = ::buffa::MessageField::none(); + self.terminal_ownership = ::buffa::EnumValue::from(0); + self.supervision = ::buffa::MessageField::none(); + self.endpoint = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for DetachedWork { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DETACHED_WORK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DetachedWork", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SupervisionPolicy is how a lost runner becomes detectable. +/// +/// It records the policy and never the heartbeat. A renewal per interval would +/// be an append per interval, into a log that is never truncated +/// (ADR#0035 facet 7), and long-lived detached work is precisely the case that +/// generates the most of them. That is the same reason FX-23 keeps a downstream +/// consumer's checkpoint flood out of Session streams: liveness is live state, +/// and live state belongs in the runner registry that a projection reads, not in +/// the history that outlives it. +/// +/// What the log holds is the number a reconciler needs afterwards. Given +/// `max_unsupervised` and the last observed supervision, whether a runner is +/// lost is a question anyone can answer later without having watched. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SupervisionPolicy { + /// How long the work may run without an observed supervisor before it is + /// presumed abandoned and becomes a reconciliation candidate. + /// + /// Field 1: `max_unsupervised` + #[serde(rename = "maxUnsupervised", alias = "max_unsupervised")] + pub max_unsupervised: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// Identity of the runner that held the work at detach time. Opaque, and + /// recorded so a reconciler can tell work whose runner is gone from work whose + /// runner is merely quiet. + /// + /// Field 2: `runner_id` + #[serde( + rename = "runnerId", + alias = "runner_id", + with = "::buffa::json_helpers::proto_string" + )] + pub runner_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for SupervisionPolicy { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SupervisionPolicy") + .field("max_unsupervised", &self.max_unsupervised) + .field("runner_id", &self.runner_id) + .finish() + } +} +impl SupervisionPolicy { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SupervisionPolicy"; +} +::buffa::impl_default_instance!(SupervisionPolicy); +impl ::buffa::MessageName for SupervisionPolicy { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "SupervisionPolicy"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.SupervisionPolicy"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SupervisionPolicy"; +} +impl ::buffa::Message for SupervisionPolicy { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + if self.max_unsupervised.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.max_unsupervised.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.runner_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.max_unsupervised.is_set() { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + self.max_unsupervised.write_to(__cache, buf); + } + ::buffa::types::put_string_field(2u32, &self.runner_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.max_unsupervised.get_or_insert_default(), + buf, + ctx, + )?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.runner_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.max_unsupervised = ::buffa::MessageField::none(); + self.runner_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SupervisionPolicy { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUPERVISION_POLICY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.SupervisionPolicy", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.__view.rs new file mode 100644 index 0000000000..abb773c1b3 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.__view.rs @@ -0,0 +1,361 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/dispatch_delegation.proto + +/// DispatchDelegation is the delegation saga's first step, run against the +/// parent: it records \[DelegationDispatched\], naming the child and what happens +/// to it when the parent reaches a terminal state. +/// +/// Write precondition At: one dispatch per operation_id, and the parent must not +/// already be terminal. +#[derive(Clone, Debug, Default)] +pub struct DispatchDelegationView<'a> { + /// The parent session. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `operation_id` + pub operation_id: &'a str, + /// Field 3: `child_session_id` + pub child_session_id: &'a str, + /// Recorded at dispatch so an orphaned child is never a silent accident + /// (ADR#0035 facet 6). + /// + /// Field 4: `cascade_policy` + pub cascade_policy: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DispatchDelegationView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `child_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_child_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `cascade_policy` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_cascade_policy(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DispatchDelegationView<'a> { + type Owned = super::super::DispatchDelegation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.child_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DispatchDelegation { + session_id: self.session_id.to_string(), + operation_id: self.operation_id.to_string(), + child_session_id: self.child_session_id.to_string(), + cascade_policy: self.cascade_policy, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DispatchDelegationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.child_session_id) as u64; + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + ::buffa::types::put_string_field(3u32, &self.child_session_id, buf); + ::buffa::types::put_int32_field(4u32, self.cascade_policy.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DispatchDelegationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("childSessionId", self.child_session_id)?; + } + { + __map.serialize_entry("cascadePolicy", &self.cascade_policy)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DispatchDelegationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DispatchDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DispatchDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchDelegation"; +} +::buffa::impl_default_view_instance!(DispatchDelegationView); +::buffa::impl_view_reborrow!(DispatchDelegationView); +/** Self-contained, `'static` owned view of a `DispatchDelegation` message. + + Wraps [`::buffa::OwnedView`]`<`[`DispatchDelegationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DispatchDelegationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DispatchDelegationOwnedView( + ::buffa::OwnedView>, +); +impl DispatchDelegationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchDelegationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchDelegationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DispatchDelegation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchDelegationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DispatchDelegationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DispatchDelegationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DispatchDelegation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The parent session. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 3: `child_session_id` + #[must_use] + pub fn child_session_id(&self) -> &'_ str { + self.0.reborrow().child_session_id + } + /// Recorded at dispatch so an orphaned child is never a silent accident + /// (ADR#0035 facet 6). + /// + /// Field 4: `cascade_policy` + #[must_use] + pub fn cascade_policy(&self) -> ::buffa::EnumValue { + self.0.reborrow().cascade_policy + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DispatchDelegationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DispatchDelegationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DispatchDelegationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DispatchDelegationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DispatchDelegation { + type View<'a> = DispatchDelegationView<'a>; + type ViewHandle = DispatchDelegationOwnedView; +} +impl ::serde::Serialize for DispatchDelegationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.rs new file mode 100644 index 0000000000..97e1327d05 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_delegation.rs @@ -0,0 +1,179 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/dispatch_delegation.proto + +/// DispatchDelegation is the delegation saga's first step, run against the +/// parent: it records \[DelegationDispatched\], naming the child and what happens +/// to it when the parent reaches a terminal state. +/// +/// Write precondition At: one dispatch per operation_id, and the parent must not +/// already be terminal. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DispatchDelegation { + /// The parent session. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 3: `child_session_id` + #[serde( + rename = "childSessionId", + alias = "child_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub child_session_id: ::buffa::alloc::string::String, + /// Recorded at dispatch so an orphaned child is never a silent accident + /// (ADR#0035 facet 6). + /// + /// Field 4: `cascade_policy` + #[serde( + rename = "cascadePolicy", + alias = "cascade_policy", + with = "::buffa::json_helpers::proto_enum" + )] + pub cascade_policy: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for DispatchDelegation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DispatchDelegation") + .field("session_id", &self.session_id) + .field("operation_id", &self.operation_id) + .field("child_session_id", &self.child_session_id) + .field("cascade_policy", &self.cascade_policy) + .finish() + } +} +impl DispatchDelegation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchDelegation"; +} +::buffa::impl_default_instance!(DispatchDelegation); +impl ::buffa::MessageName for DispatchDelegation { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DispatchDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DispatchDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchDelegation"; +} +impl ::buffa::Message for DispatchDelegation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.child_session_id) as u64; + { + let val = self.cascade_policy.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + ::buffa::types::put_string_field(3u32, &self.child_session_id, buf); + ::buffa::types::put_int32_field(4u32, self.cascade_policy.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.child_session_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cascade_policy = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.operation_id.clear(); + self.child_session_id.clear(); + self.cascade_policy = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DispatchDelegation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DISPATCH_DELEGATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchDelegation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.__view.rs new file mode 100644 index 0000000000..0671949be9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.__view.rs @@ -0,0 +1,496 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/dispatch_external_delegation.proto + +/// DispatchExternalDelegation hands work to an agent outside this store, +/// recording \[ExternalDelegationDispatched\]. +/// +/// Write precondition At: one dispatch per operation_id. +#[derive(Clone, Debug, Default)] +pub struct DispatchExternalDelegationView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `operation_id` + pub operation_id: &'a str, + /// Field 3: `delegate_reference` + pub delegate_reference: &'a str, + /// Field 4: `authenticated_remote_subject` + pub authenticated_remote_subject: &'a str, + /// Field 5: `authorization_reference` + pub authorization_reference: &'a str, + /// Field 6: `request_digest` + pub request_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 7: `correlation_id` + pub correlation_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> DispatchExternalDelegationView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `delegate_reference` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_delegate_reference(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `authenticated_remote_subject` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_authenticated_remote_subject(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `authorization_reference` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_authorization_reference(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `request_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_request_digest(&self) -> bool { + self.request_digest.is_set() + } + /**Whether required field `correlation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_correlation_id(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for DispatchExternalDelegationView<'a> { + type Owned = super::super::DispatchExternalDelegation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.delegate_reference = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.authenticated_remote_subject = ::buffa::types::borrow_str( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.authorization_reference = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.request_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.request_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.correlation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::DispatchExternalDelegation, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::DispatchExternalDelegation, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::DispatchExternalDelegation { + session_id: self.session_id.to_string(), + operation_id: self.operation_id.to_string(), + delegate_reference: self.delegate_reference.to_string(), + authenticated_remote_subject: self.authenticated_remote_subject.to_string(), + authorization_reference: self.authorization_reference.to_string(), + request_digest: match self.request_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + correlation_id: self.correlation_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for DispatchExternalDelegationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.delegate_reference) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.authenticated_remote_subject) + as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.authorization_reference) + as u64; + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.correlation_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + ::buffa::types::put_string_field(3u32, &self.delegate_reference, buf); + ::buffa::types::put_string_field(4u32, &self.authenticated_remote_subject, buf); + ::buffa::types::put_string_field(5u32, &self.authorization_reference, buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.correlation_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for DispatchExternalDelegationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + __map.serialize_entry("delegateReference", self.delegate_reference)?; + } + { + __map + .serialize_entry( + "authenticatedRemoteSubject", + self.authenticated_remote_subject, + )?; + } + { + __map + .serialize_entry( + "authorizationReference", + self.authorization_reference, + )?; + } + { + if let ::core::option::Option::Some(__v) = self.request_digest.as_option() { + __map.serialize_entry("requestDigest", __v)?; + } + } + { + __map.serialize_entry("correlationId", self.correlation_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for DispatchExternalDelegationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DispatchExternalDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DispatchExternalDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchExternalDelegation"; +} +::buffa::impl_default_view_instance!(DispatchExternalDelegationView); +::buffa::impl_view_reborrow!(DispatchExternalDelegationView); +/** Self-contained, `'static` owned view of a `DispatchExternalDelegation` message. + + Wraps [`::buffa::OwnedView`]`<`[`DispatchExternalDelegationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`DispatchExternalDelegationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct DispatchExternalDelegationOwnedView( + ::buffa::OwnedView>, +); +impl DispatchExternalDelegationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchExternalDelegationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchExternalDelegationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::DispatchExternalDelegation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + DispatchExternalDelegationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`DispatchExternalDelegationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &DispatchExternalDelegationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::DispatchExternalDelegation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 3: `delegate_reference` + #[must_use] + pub fn delegate_reference(&self) -> &'_ str { + self.0.reborrow().delegate_reference + } + /// Field 4: `authenticated_remote_subject` + #[must_use] + pub fn authenticated_remote_subject(&self) -> &'_ str { + self.0.reborrow().authenticated_remote_subject + } + /// Field 5: `authorization_reference` + #[must_use] + pub fn authorization_reference(&self) -> &'_ str { + self.0.reborrow().authorization_reference + } + /// Field 6: `request_digest` + #[must_use] + pub fn request_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().request_digest + } + /// Field 7: `correlation_id` + #[must_use] + pub fn correlation_id(&self) -> &'_ str { + self.0.reborrow().correlation_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for DispatchExternalDelegationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + DispatchExternalDelegationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: DispatchExternalDelegationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for DispatchExternalDelegationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::DispatchExternalDelegation { + type View<'a> = DispatchExternalDelegationView<'a>; + type ViewHandle = DispatchExternalDelegationOwnedView; +} +impl ::serde::Serialize for DispatchExternalDelegationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.rs new file mode 100644 index 0000000000..c67e0c4510 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.dispatch_external_delegation.rs @@ -0,0 +1,246 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/dispatch_external_delegation.proto + +/// DispatchExternalDelegation hands work to an agent outside this store, +/// recording \[ExternalDelegationDispatched\]. +/// +/// Write precondition At: one dispatch per operation_id. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct DispatchExternalDelegation { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 3: `delegate_reference` + #[serde( + rename = "delegateReference", + alias = "delegate_reference", + with = "::buffa::json_helpers::proto_string" + )] + pub delegate_reference: ::buffa::alloc::string::String, + /// Field 4: `authenticated_remote_subject` + #[serde( + rename = "authenticatedRemoteSubject", + alias = "authenticated_remote_subject", + with = "::buffa::json_helpers::proto_string" + )] + pub authenticated_remote_subject: ::buffa::alloc::string::String, + /// Field 5: `authorization_reference` + #[serde( + rename = "authorizationReference", + alias = "authorization_reference", + with = "::buffa::json_helpers::proto_string" + )] + pub authorization_reference: ::buffa::alloc::string::String, + /// Field 6: `request_digest` + #[serde(rename = "requestDigest", alias = "request_digest")] + pub request_digest: ::buffa::MessageField>, + /// Field 7: `correlation_id` + #[serde( + rename = "correlationId", + alias = "correlation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub correlation_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for DispatchExternalDelegation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DispatchExternalDelegation") + .field("session_id", &self.session_id) + .field("operation_id", &self.operation_id) + .field("delegate_reference", &self.delegate_reference) + .field("authenticated_remote_subject", &self.authenticated_remote_subject) + .field("authorization_reference", &self.authorization_reference) + .field("request_digest", &self.request_digest) + .field("correlation_id", &self.correlation_id) + .finish() + } +} +impl DispatchExternalDelegation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchExternalDelegation"; +} +::buffa::impl_default_instance!(DispatchExternalDelegation); +impl ::buffa::MessageName for DispatchExternalDelegation { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "DispatchExternalDelegation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.DispatchExternalDelegation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchExternalDelegation"; +} +impl ::buffa::Message for DispatchExternalDelegation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.delegate_reference) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.authenticated_remote_subject) + as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.authorization_reference) + as u64; + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.correlation_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + ::buffa::types::put_string_field(3u32, &self.delegate_reference, buf); + ::buffa::types::put_string_field(4u32, &self.authenticated_remote_subject, buf); + ::buffa::types::put_string_field(5u32, &self.authorization_reference, buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.correlation_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.delegate_reference, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + &mut self.authenticated_remote_subject, + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.authorization_reference, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.request_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.correlation_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.operation_id.clear(); + self.delegate_reference.clear(); + self.authenticated_remote_subject.clear(); + self.authorization_reference.clear(); + self.request_digest = ::buffa::MessageField::none(); + self.correlation_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for DispatchExternalDelegation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DISPATCH_EXTERNAL_DELEGATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.DispatchExternalDelegation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.__view.rs new file mode 100644 index 0000000000..351d990adb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.__view.rs @@ -0,0 +1,424 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/end_execution_attempt.proto + +/// EndExecutionAttempt releases the session from an attempt, recording +/// \[ExecutionAttemptEnded\]. +/// +/// Write precondition At: one outcome per attempt. +#[derive(Clone, Debug, Default)] +pub struct EndExecutionAttemptView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_attempt_id` + pub execution_attempt_id: &'a str, + /// Field 3: `outcome` + pub outcome: ::buffa::EnumValue, + /// Field 4: `detail` + pub detail: ::core::option::Option<&'a str>, + /// Field 5: `ended_at` + pub ended_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> EndExecutionAttemptView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_attempt_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_attempt_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `outcome` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `ended_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ended_at(&self) -> bool { + self.ended_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for EndExecutionAttemptView<'a> { + type Owned = super::super::EndExecutionAttempt; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.execution_attempt_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ended_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.ended_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::EndExecutionAttempt, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::EndExecutionAttempt, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::EndExecutionAttempt { + session_id: self.session_id.to_string(), + execution_attempt_id: self.execution_attempt_id.to_string(), + outcome: self.outcome, + detail: self.detail.map(|s| s.to_string()), + ended_at: match self.ended_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for EndExecutionAttemptView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.ended_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ended_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + ::buffa::types::put_int32_field(3u32, self.outcome.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.ended_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ended_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for EndExecutionAttemptView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("executionAttemptId", self.execution_attempt_id)?; + } + { + __map.serialize_entry("outcome", &self.outcome)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.ended_at.as_option() { + __map.serialize_entry("endedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for EndExecutionAttemptView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "EndExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.EndExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EndExecutionAttempt"; +} +::buffa::impl_default_view_instance!(EndExecutionAttemptView); +::buffa::impl_view_reborrow!(EndExecutionAttemptView); +/** Self-contained, `'static` owned view of a `EndExecutionAttempt` message. + + Wraps [`::buffa::OwnedView`]`<`[`EndExecutionAttemptView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`EndExecutionAttemptView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct EndExecutionAttemptOwnedView( + ::buffa::OwnedView>, +); +impl EndExecutionAttemptOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EndExecutionAttemptOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EndExecutionAttemptOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::EndExecutionAttempt, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EndExecutionAttemptOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`EndExecutionAttemptView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &EndExecutionAttemptView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::EndExecutionAttempt { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_attempt_id` + #[must_use] + pub fn execution_attempt_id(&self) -> &'_ str { + self.0.reborrow().execution_attempt_id + } + /// Field 3: `outcome` + #[must_use] + pub fn outcome(&self) -> ::buffa::EnumValue { + self.0.reborrow().outcome + } + /// Field 4: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } + /// Field 5: `ended_at` + #[must_use] + pub fn ended_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().ended_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for EndExecutionAttemptOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + EndExecutionAttemptOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: EndExecutionAttemptOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for EndExecutionAttemptOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::EndExecutionAttempt { + type View<'a> = EndExecutionAttemptView<'a>; + type ViewHandle = EndExecutionAttemptOwnedView; +} +impl ::serde::Serialize for EndExecutionAttemptOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.rs new file mode 100644 index 0000000000..a1fa0c610e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.end_execution_attempt.rs @@ -0,0 +1,220 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/end_execution_attempt.proto + +/// EndExecutionAttempt releases the session from an attempt, recording +/// \[ExecutionAttemptEnded\]. +/// +/// Write precondition At: one outcome per attempt. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct EndExecutionAttempt { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_attempt_id` + #[serde( + rename = "executionAttemptId", + alias = "execution_attempt_id", + with = "::buffa::json_helpers::proto_string" + )] + pub execution_attempt_id: ::buffa::alloc::string::String, + /// Field 3: `outcome` + #[serde(rename = "outcome", with = "::buffa::json_helpers::proto_enum")] + pub outcome: ::buffa::EnumValue, + /// Field 4: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 5: `ended_at` + #[serde(rename = "endedAt", alias = "ended_at")] + pub ended_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for EndExecutionAttempt { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("EndExecutionAttempt") + .field("session_id", &self.session_id) + .field("execution_attempt_id", &self.execution_attempt_id) + .field("outcome", &self.outcome) + .field("detail", &self.detail) + .field("ended_at", &self.ended_at) + .finish() + } +} +impl EndExecutionAttempt { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EndExecutionAttempt"; +} +impl EndExecutionAttempt { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(EndExecutionAttempt); +impl ::buffa::MessageName for EndExecutionAttempt { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "EndExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.EndExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EndExecutionAttempt"; +} +impl ::buffa::Message for EndExecutionAttempt { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.ended_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ended_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + ::buffa::types::put_int32_field(3u32, self.outcome.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.ended_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ended_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.execution_attempt_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.ended_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_attempt_id.clear(); + self.outcome = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + self.ended_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for EndExecutionAttempt { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __END_EXECUTION_ATTEMPT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.EndExecutionAttempt", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.__view.rs new file mode 100644 index 0000000000..a35dad4a47 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.__view.rs @@ -0,0 +1,309 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/erase_artifact.proto + +/// EraseArtifact removes claim-checked bytes an event referenced, recording +/// \[ArtifactErased\]. The event that referenced them stays on the log; only the +/// out-of-line payload goes. +/// +/// Write precondition At: the artifact must exist and be claim-checked, verified +/// at the command boundary against the artifact store rather than from folded +/// state. +#[derive(Clone, Debug, Default)] +pub struct EraseArtifactView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `artifact_id` + pub artifact_id: &'a str, + /// Field 3: `reason` + pub reason: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> EraseArtifactView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifact_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for EraseArtifactView<'a> { + type Owned = super::super::EraseArtifact; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.artifact_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::EraseArtifact { + session_id: self.session_id.to_string(), + artifact_id: self.artifact_id.to_string(), + reason: self.reason.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for EraseArtifactView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for EraseArtifactView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("artifactId", self.artifact_id)?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for EraseArtifactView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "EraseArtifact"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.EraseArtifact"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EraseArtifact"; +} +::buffa::impl_default_view_instance!(EraseArtifactView); +::buffa::impl_view_reborrow!(EraseArtifactView); +/** Self-contained, `'static` owned view of a `EraseArtifact` message. + + Wraps [`::buffa::OwnedView`]`<`[`EraseArtifactView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`EraseArtifactView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct EraseArtifactOwnedView(::buffa::OwnedView>); +impl EraseArtifactOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EraseArtifactOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EraseArtifactOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::EraseArtifact, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + EraseArtifactOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`EraseArtifactView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &EraseArtifactView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::EraseArtifact { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `artifact_id` + #[must_use] + pub fn artifact_id(&self) -> &'_ str { + self.0.reborrow().artifact_id + } + /// Field 3: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for EraseArtifactOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + EraseArtifactOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: EraseArtifactOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for EraseArtifactOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::EraseArtifact { + type View<'a> = EraseArtifactView<'a>; + type ViewHandle = EraseArtifactOwnedView; +} +impl ::serde::Serialize for EraseArtifactOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.rs new file mode 100644 index 0000000000..96215fe6e9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.erase_artifact.rs @@ -0,0 +1,167 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/erase_artifact.proto + +/// EraseArtifact removes claim-checked bytes an event referenced, recording +/// \[ArtifactErased\]. The event that referenced them stays on the log; only the +/// out-of-line payload goes. +/// +/// Write precondition At: the artifact must exist and be claim-checked, verified +/// at the command boundary against the artifact store rather than from folded +/// state. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct EraseArtifact { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `artifact_id` + #[serde( + rename = "artifactId", + alias = "artifact_id", + with = "::buffa::json_helpers::proto_string" + )] + pub artifact_id: ::buffa::alloc::string::String, + /// Field 3: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for EraseArtifact { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("EraseArtifact") + .field("session_id", &self.session_id) + .field("artifact_id", &self.artifact_id) + .field("reason", &self.reason) + .finish() + } +} +impl EraseArtifact { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EraseArtifact"; +} +impl EraseArtifact { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(EraseArtifact); +impl ::buffa::MessageName for EraseArtifact { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "EraseArtifact"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.EraseArtifact"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.EraseArtifact"; +} +impl ::buffa::Message for EraseArtifact { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.artifact_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.artifact_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.artifact_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.artifact_id.clear(); + self.reason = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for EraseArtifact { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __ERASE_ARTIFACT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.EraseArtifact", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__oneof.rs index 463ae4f298..bb76764968 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__oneof.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__oneof.rs @@ -15,6 +15,9 @@ pub mod session_event { SessionHidden(::buffa::alloc::boxed::Box), SessionForked(::buffa::alloc::boxed::Box), SessionRewound(::buffa::alloc::boxed::Box), + SessionRecovered( + ::buffa::alloc::boxed::Box, + ), Compacted(::buffa::alloc::boxed::Box), UserMessageRecorded( ::buffa::alloc::boxed::Box, @@ -28,6 +31,9 @@ pub mod session_event { AssistantMessageFailed( ::buffa::alloc::boxed::Box, ), + ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box, + ), ToolCallRequested( ::buffa::alloc::boxed::Box, ), @@ -173,6 +179,16 @@ pub mod session_event { Self::Some(Event::from(v)) } } + impl From for Event { + fn from(v: super::super::super::SessionRecovered) -> Self { + Self::SessionRecovered(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::SessionRecovered) -> Self { + Self::Some(Event::from(v)) + } + } impl From for Event { fn from(v: super::super::super::Compacted) -> Self { Self::Compacted(::buffa::alloc::boxed::Box::new(v)) @@ -227,6 +243,17 @@ pub mod session_event { Self::Some(Event::from(v)) } } + impl From for Event { + fn from(v: super::super::super::ProviderToolIntentRejected) -> Self { + Self::ProviderToolIntentRejected(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::ProviderToolIntentRejected) -> Self { + Self::Some(Event::from(v)) + } + } impl From for Event { fn from(v: super::super::super::ToolCallRequested) -> Self { Self::ToolCallRequested(::buffa::alloc::boxed::Box::new(v)) @@ -557,6 +584,9 @@ pub mod session_event { Self::SessionRewound(v) => { map.serialize_entry("sessionRewound", v)?; } + Self::SessionRecovered(v) => { + map.serialize_entry("sessionRecovered", v)?; + } Self::Compacted(v) => { map.serialize_entry("compacted", v)?; } @@ -572,6 +602,9 @@ pub mod session_event { Self::AssistantMessageFailed(v) => { map.serialize_entry("assistantMessageFailed", v)?; } + Self::ProviderToolIntentRejected(v) => { + map.serialize_entry("providerToolIntentRejected", v)?; + } Self::ToolCallRequested(v) => { map.serialize_entry("toolCallRequested", v)?; } diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view.rs index 8c986d015c..c422914ccb 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view.rs @@ -276,6 +276,37 @@ impl<'a> ::buffa::MessageView<'a> for SessionEventView<'a> { ); } } + 42u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + ref mut existing, + ), + ) = view.event + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.event = Some( + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } 8u32 => { ::buffa::encoding::check_wire_type( tag, @@ -431,6 +462,37 @@ impl<'a> ::buffa::MessageView<'a> for SessionEventView<'a> { ); } } + 43u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + ref mut existing, + ), + ) = view.event + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.event = Some( + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } 12u32 => { ::buffa::encoding::check_wire_type( tag, @@ -1417,6 +1479,15 @@ impl<'a> ::buffa::MessageView<'a> for SessionEventView<'a> { ), ) } + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + v, + ) => { + super::super::__buffa::oneof::session_event::Event::SessionRecovered( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } super::super::__buffa::view::oneof::session_event::Event::Compacted( v, ) => { @@ -1462,6 +1533,15 @@ impl<'a> ::buffa::MessageView<'a> for SessionEventView<'a> { ), ) } + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + v, + ) => { + super::super::__buffa::oneof::session_event::Event::ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } super::super::__buffa::view::oneof::session_event::Event::ToolCallRequested( v, ) => { @@ -1810,6 +1890,16 @@ impl<'a> ::buffa::ViewEncode<'a> for SessionEventView<'a> { += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; } + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } super::super::__buffa::view::oneof::session_event::Event::Compacted( x, ) => { @@ -1860,6 +1950,16 @@ impl<'a> ::buffa::ViewEncode<'a> for SessionEventView<'a> { += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; } + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } super::super::__buffa::view::oneof::session_event::Event::ToolCallRequested( x, ) => { @@ -2234,6 +2334,16 @@ impl<'a> ::buffa::ViewEncode<'a> for SessionEventView<'a> { ); x.write_to(__cache, buf); } + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 42u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } super::super::__buffa::view::oneof::session_event::Event::Compacted( x, ) => { @@ -2284,6 +2394,16 @@ impl<'a> ::buffa::ViewEncode<'a> for SessionEventView<'a> { ); x.write_to(__cache, buf); } + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 43u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } super::super::__buffa::view::oneof::session_event::Event::ToolCallRequested( x, ) => { @@ -2633,6 +2753,11 @@ impl<'__a> ::serde::Serialize for SessionEventView<'__a> { ) => { __map.serialize_entry("sessionRewound", v)?; } + super::super::__buffa::view::oneof::session_event::Event::SessionRecovered( + v, + ) => { + __map.serialize_entry("sessionRecovered", v)?; + } super::super::__buffa::view::oneof::session_event::Event::Compacted( v, ) => { @@ -2658,6 +2783,11 @@ impl<'__a> ::serde::Serialize for SessionEventView<'__a> { ) => { __map.serialize_entry("assistantMessageFailed", v)?; } + super::super::__buffa::view::oneof::session_event::Event::ProviderToolIntentRejected( + v, + ) => { + __map.serialize_entry("providerToolIntentRejected", v)?; + } super::super::__buffa::view::oneof::session_event::Event::ToolCallRequested( v, ) => { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view_oneof.rs index fb27c1f254..678ec92ad3 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view_oneof.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.__view_oneof.rs @@ -41,6 +41,11 @@ pub mod session_event { super::super::super::super::__buffa::view::SessionRewoundView<'a>, >, ), + SessionRecovered( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::SessionRecoveredView<'a>, + >, + ), Compacted( ::buffa::alloc::boxed::Box< super::super::super::super::__buffa::view::CompactedView<'a>, @@ -70,6 +75,13 @@ pub mod session_event { super::super::super::super::__buffa::view::AssistantMessageFailedView<'a>, >, ), + ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::ProviderToolIntentRejectedView< + 'a, + >, + >, + ), ToolCallRequested( ::buffa::alloc::boxed::Box< super::super::super::super::__buffa::view::ToolCallRequestedView<'a>, diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.rs index f42495e032..5330029e8d 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.events.rs @@ -122,6 +122,14 @@ impl ::buffa::Message for SessionEvent { += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; } + __buffa::oneof::session_event::Event::SessionRecovered(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } __buffa::oneof::session_event::Event::Compacted(x) => { let __slot = __cache.reserve(); let inner = x.compute_size(__cache); @@ -162,6 +170,14 @@ impl ::buffa::Message for SessionEvent { += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + inner as u64; } + __buffa::oneof::session_event::Event::ProviderToolIntentRejected(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 2u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } __buffa::oneof::session_event::Event::ToolCallRequested(x) => { let __slot = __cache.reserve(); let inner = x.compute_size(__cache); @@ -467,6 +483,14 @@ impl ::buffa::Message for SessionEvent { ); x.write_to(__cache, buf); } + __buffa::oneof::session_event::Event::SessionRecovered(x) => { + ::buffa::types::put_len_delimited_header( + 42u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } __buffa::oneof::session_event::Event::Compacted(x) => { ::buffa::types::put_len_delimited_header( 8u32, @@ -507,6 +531,14 @@ impl ::buffa::Message for SessionEvent { ); x.write_to(__cache, buf); } + __buffa::oneof::session_event::Event::ProviderToolIntentRejected(x) => { + ::buffa::types::put_len_delimited_header( + 43u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } __buffa::oneof::session_event::Event::ToolCallRequested(x) => { ::buffa::types::put_len_delimited_header( 12u32, @@ -903,6 +935,28 @@ impl ::buffa::Message for SessionEvent { ); } } + 42u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::session_event::Event::SessionRecovered( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.event = ::core::option::Option::Some( + __buffa::oneof::session_event::Event::SessionRecovered( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } 8u32 => { ::buffa::encoding::check_wire_type( tag, @@ -1011,6 +1065,28 @@ impl ::buffa::Message for SessionEvent { ); } } + 43u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::session_event::Event::ProviderToolIntentRejected( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.event = ::core::option::Option::Some( + __buffa::oneof::session_event::Event::ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } 12u32 => { ::buffa::encoding::check_wire_type( tag, @@ -1841,6 +1917,30 @@ impl<'de> serde::Deserialize<'de> for SessionEvent { ); } } + "sessionRecovered" | "session_recovered" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + SessionRecovered, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + __buffa::oneof::session_event::Event::SessionRecovered( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } "compacted" => { let v: ::core::option::Option = map .next_value_seed( @@ -1961,6 +2061,31 @@ impl<'de> serde::Deserialize<'de> for SessionEvent { ); } } + "providerToolIntentRejected" + | "provider_tool_intent_rejected" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + ProviderToolIntentRejected, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + __buffa::oneof::session_event::Event::ProviderToolIntentRejected( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } "toolCallRequested" | "tool_call_requested" => { let v: ::core::option::Option = map .next_value_seed( diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.__view.rs new file mode 100644 index 0000000000..07a44a9055 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.__view.rs @@ -0,0 +1,451 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_assistant_message.proto + +/// FailAssistantMessage settles an assistant turn that was interrupted, +/// cancelled, or errored, recording \[AssistantMessageFailed\], so every started +/// message has a determinable outcome. +/// +/// Write precondition Any: per message_id this competes with +/// CompleteAssistantMessage under first-terminal-outcome-wins. +#[derive(Clone, Debug, Default)] +pub struct FailAssistantMessageView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `message_id` + pub message_id: &'a str, + /// Field 3: `reason` + pub reason: ::buffa::EnumValue, + /// Field 4: `detail` + pub detail: ::core::option::Option<&'a str>, + /// Tokens billed for the partial turn, so a cost fold does not undercount + /// a turn that failed mid-generation. + /// + /// Field 5: `usage` + pub usage: ::buffa::MessageFieldView< + super::super::__buffa::view::TokenUsageView<'a>, + >, + /// Field 6: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> FailAssistantMessageView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for FailAssistantMessageView<'a> { + type Owned = super::super::FailAssistantMessage; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.usage.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.usage = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::FailAssistantMessage, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::FailAssistantMessage, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::FailAssistantMessage { + session_id: self.session_id.to_string(), + message_id: self.message_id.to_string(), + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + usage: match self.usage.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::TokenUsage, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for FailAssistantMessageView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.message_id, buf); + ::buffa::types::put_int32_field(3u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + ::buffa::types::put_string_field(6u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for FailAssistantMessageView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("messageId", self.message_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.usage.as_option() { + __map.serialize_entry("usage", __v)?; + } + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for FailAssistantMessageView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailAssistantMessage"; +} +::buffa::impl_default_view_instance!(FailAssistantMessageView); +::buffa::impl_view_reborrow!(FailAssistantMessageView); +/** Self-contained, `'static` owned view of a `FailAssistantMessage` message. + + Wraps [`::buffa::OwnedView`]`<`[`FailAssistantMessageView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FailAssistantMessageView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct FailAssistantMessageOwnedView( + ::buffa::OwnedView>, +); +impl FailAssistantMessageOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailAssistantMessageOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailAssistantMessageOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::FailAssistantMessage, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailAssistantMessageOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`FailAssistantMessageView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &FailAssistantMessageView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::FailAssistantMessage { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `message_id` + #[must_use] + pub fn message_id(&self) -> &'_ str { + self.0.reborrow().message_id + } + /// Field 3: `reason` + #[must_use] + pub fn reason( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 4: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } + /// Tokens billed for the partial turn, so a cost fold does not undercount + /// a turn that failed mid-generation. + /// + /// Field 5: `usage` + #[must_use] + pub fn usage( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().usage + } + /// Field 6: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for FailAssistantMessageOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + FailAssistantMessageOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: FailAssistantMessageOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for FailAssistantMessageOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::FailAssistantMessage { + type View<'a> = FailAssistantMessageView<'a>; + type ViewHandle = FailAssistantMessageOwnedView; +} +impl ::serde::Serialize for FailAssistantMessageOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.rs new file mode 100644 index 0000000000..7e802a3600 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_assistant_message.rs @@ -0,0 +1,241 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_assistant_message.proto + +/// FailAssistantMessage settles an assistant turn that was interrupted, +/// cancelled, or errored, recording \[AssistantMessageFailed\], so every started +/// message has a determinable outcome. +/// +/// Write precondition Any: per message_id this competes with +/// CompleteAssistantMessage under first-terminal-outcome-wins. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct FailAssistantMessage { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `message_id` + #[serde( + rename = "messageId", + alias = "message_id", + with = "::buffa::json_helpers::proto_string" + )] + pub message_id: ::buffa::alloc::string::String, + /// Field 3: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 4: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, + /// Tokens billed for the partial turn, so a cost fold does not undercount + /// a turn that failed mid-generation. + /// + /// Field 5: `usage` + #[serde( + rename = "usage", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub usage: ::buffa::MessageField>, + /// Field 6: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for FailAssistantMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FailAssistantMessage") + .field("session_id", &self.session_id) + .field("message_id", &self.message_id) + .field("reason", &self.reason) + .field("detail", &self.detail) + .field("usage", &self.usage) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl FailAssistantMessage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailAssistantMessage"; +} +impl FailAssistantMessage { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(FailAssistantMessage); +impl ::buffa::MessageName for FailAssistantMessage { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailAssistantMessage"; +} +impl ::buffa::Message for FailAssistantMessage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.message_id, buf); + ::buffa::types::put_int32_field(3u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + ::buffa::types::put_string_field(6u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.usage.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.message_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + self.usage = ::buffa::MessageField::none(); + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for FailAssistantMessage { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FAIL_ASSISTANT_MESSAGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailAssistantMessage", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.__view.rs new file mode 100644 index 0000000000..23ed853419 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.__view.rs @@ -0,0 +1,310 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_session.proto + +/// FailSession seals a session as failed, recording \[SessionFailed\]. +/// +/// Write precondition At: rejected if the session is already terminal. +#[derive(Clone, Debug, Default)] +pub struct FailSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `reason` + pub reason: ::buffa::EnumValue, + /// Field 3: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> FailSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for FailSessionView<'a> { + type Owned = super::super::FailSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::FailSession { + session_id: self.session_id.to_string(), + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for FailSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for FailSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for FailSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailSession"; +} +::buffa::impl_default_view_instance!(FailSessionView); +::buffa::impl_view_reborrow!(FailSessionView); +/** Self-contained, `'static` owned view of a `FailSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`FailSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FailSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct FailSessionOwnedView(::buffa::OwnedView>); +impl FailSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::FailSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`FailSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &FailSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::FailSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 3: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for FailSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + FailSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: FailSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for FailSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::FailSession { + type View<'a> = FailSessionView<'a>; + type ViewHandle = FailSessionOwnedView; +} +impl ::serde::Serialize for FailSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.rs new file mode 100644 index 0000000000..ba05fc8407 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_session.rs @@ -0,0 +1,164 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_session.proto + +/// FailSession seals a session as failed, recording \[SessionFailed\]. +/// +/// Write precondition At: rejected if the session is already terminal. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct FailSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 3: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for FailSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FailSession") + .field("session_id", &self.session_id) + .field("reason", &self.reason) + .field("detail", &self.detail) + .finish() + } +} +impl FailSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailSession"; +} +impl FailSession { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(FailSession); +impl ::buffa::MessageName for FailSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailSession"; +} +impl ::buffa::Message for FailSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for FailSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FAIL_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.__view.rs new file mode 100644 index 0000000000..769321f94e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.__view.rs @@ -0,0 +1,406 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_tool_call.proto + +/// FailToolCall settles a call with an error, recording \[ToolCallFailed\]. It is +/// how a reconciler rejects a call it found interrupted, with reason +/// TOOL_CALL_FAILURE_REASON_INTERRUPTED. +/// +/// Write precondition Any: first-terminal-outcome-wins against CompleteToolCall, +/// keyed on tool_execution_id. +#[derive(Clone, Debug, Default)] +pub struct FailToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `error` + pub error: &'a str, + /// Field 5: `reason` + pub reason: ::buffa::EnumValue, + /// Field 6: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> FailToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `error` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_error(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for FailToolCallView<'a> { + type Owned = super::super::FailToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.error = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::FailToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + error: self.error.to_string(), + reason: self.reason, + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for FailToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.error) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.error, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for FailToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("error", self.error)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for FailToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailToolCall"; +} +::buffa::impl_default_view_instance!(FailToolCallView); +::buffa::impl_view_reborrow!(FailToolCallView); +/** Self-contained, `'static` owned view of a `FailToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`FailToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FailToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct FailToolCallOwnedView(::buffa::OwnedView>); +impl FailToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailToolCallOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::FailToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + FailToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`FailToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &FailToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::FailToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `error` + #[must_use] + pub fn error(&self) -> &'_ str { + self.0.reborrow().error + } + /// Field 5: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 6: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for FailToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + FailToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: FailToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for FailToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::FailToolCall { + type View<'a> = FailToolCallView<'a>; + type ViewHandle = FailToolCallOwnedView; +} +impl ::serde::Serialize for FailToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.rs new file mode 100644 index 0000000000..e4f2962862 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fail_tool_call.rs @@ -0,0 +1,203 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fail_tool_call.proto + +/// FailToolCall settles a call with an error, recording \[ToolCallFailed\]. It is +/// how a reconciler rejects a call it found interrupted, with reason +/// TOOL_CALL_FAILURE_REASON_INTERRUPTED. +/// +/// Write precondition Any: first-terminal-outcome-wins against CompleteToolCall, +/// keyed on tool_execution_id. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct FailToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `error` + #[serde(rename = "error", with = "::buffa::json_helpers::proto_string")] + pub error: ::buffa::alloc::string::String, + /// Field 5: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 6: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for FailToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FailToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("error", &self.error) + .field("reason", &self.reason) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl FailToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailToolCall"; +} +::buffa::impl_default_instance!(FailToolCall); +impl ::buffa::MessageName for FailToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "FailToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.FailToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailToolCall"; +} +impl ::buffa::Message for FailToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.error) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.error, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.error, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.error.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for FailToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FAIL_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.FailToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_change.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_change.rs index 128a91940a..e43f951683 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_change.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_change.rs @@ -10,6 +10,11 @@ pub enum FileChangeKind { FILE_CHANGE_KIND_MODIFIED = 2i32, FILE_CHANGE_KIND_DELETED = 3i32, FILE_CHANGE_KIND_RENAMED = 4i32, + /// Content duplicated from another path, which still exists. Recorded instead + /// of FILE_CHANGE_KIND_CREATED rather than alongside it, so the destination has + /// exactly one kind and two facts about the same change cannot disagree. The + /// source file did not change and produces no FileChanged of its own. + FILE_CHANGE_KIND_COPIED = 5i32, } impl FileChangeKind { ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_UNSPECIFIED`]; `Debug` prints the variant name. @@ -27,6 +32,9 @@ impl FileChangeKind { ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_RENAMED`]; `Debug` prints the variant name. #[allow(non_upper_case_globals)] pub const Renamed: Self = Self::FILE_CHANGE_KIND_RENAMED; + ///Idiomatic alias for [`Self::FILE_CHANGE_KIND_COPIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Copied: Self = Self::FILE_CHANGE_KIND_COPIED; } impl ::core::default::Default for FileChangeKind { fn default() -> Self { @@ -129,6 +137,7 @@ impl ::buffa::Enumeration for FileChangeKind { 2i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_MODIFIED), 3i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_DELETED), 4i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_RENAMED), + 5i32 => ::core::option::Option::Some(Self::FILE_CHANGE_KIND_COPIED), _ => ::core::option::Option::None, } } @@ -142,6 +151,7 @@ impl ::buffa::Enumeration for FileChangeKind { Self::FILE_CHANGE_KIND_MODIFIED => "FILE_CHANGE_KIND_MODIFIED", Self::FILE_CHANGE_KIND_DELETED => "FILE_CHANGE_KIND_DELETED", Self::FILE_CHANGE_KIND_RENAMED => "FILE_CHANGE_KIND_RENAMED", + Self::FILE_CHANGE_KIND_COPIED => "FILE_CHANGE_KIND_COPIED", } } fn from_proto_name(name: &str) -> ::core::option::Option { @@ -161,6 +171,9 @@ impl ::buffa::Enumeration for FileChangeKind { "FILE_CHANGE_KIND_RENAMED" => { ::core::option::Option::Some(Self::FILE_CHANGE_KIND_RENAMED) } + "FILE_CHANGE_KIND_COPIED" => { + ::core::option::Option::Some(Self::FILE_CHANGE_KIND_COPIED) + } _ => ::core::option::Option::None, } } @@ -171,6 +184,7 @@ impl ::buffa::Enumeration for FileChangeKind { Self::FILE_CHANGE_KIND_MODIFIED, Self::FILE_CHANGE_KIND_DELETED, Self::FILE_CHANGE_KIND_RENAMED, + Self::FILE_CHANGE_KIND_COPIED, ] } } diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.__view.rs index 0720ed1b46..359d141dbc 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.__view.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.__view.rs @@ -25,7 +25,9 @@ pub struct FileChangedView<'a> { pub path: &'a str, /// Field 3: `change_kind` pub change_kind: ::buffa::EnumValue, - /// Same workspace-relative form as path. + /// Where a renamed file used to be, in the same workspace-relative form as + /// path. Rename only: a copy sets copied_from instead, because a previous path + /// asserts the file is no longer there. /// /// Field 4: `previous_path` pub previous_path: ::core::option::Option<&'a str>, @@ -61,6 +63,12 @@ pub struct FileChangedView<'a> { pub diff: ::buffa::MessageFieldView< super::super::__buffa::view::DiffSummaryView<'a>, >, + /// Where the content came from, set only for FILE_CHANGE_KIND_COPIED. + /// + /// Field 10: `copied_from` + pub copied_from: ::buffa::MessageFieldView< + super::super::__buffa::view::CopySourceView<'a>, + >, #[doc(hidden)] pub __buffa_required_seen_0: u64, } @@ -246,6 +254,27 @@ impl<'a> ::buffa::MessageView<'a> for FileChangedView<'a> { } } } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.copied_from.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.copied_from = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } _ => { ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; } @@ -299,6 +328,15 @@ impl<'a> ::buffa::MessageView<'a> for FileChangedView<'a> { } None => ::buffa::MessageField::none(), }, + copied_from: match self.copied_from.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CopySource, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, ..::core::default::Default::default() }) } @@ -344,6 +382,14 @@ impl<'a> ::buffa::ViewEncode<'a> for FileChangedView<'a> { += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + if self.copied_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.copied_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } ::buffa::saturate_size(size) } #[allow(clippy::needless_borrow)] @@ -386,6 +432,14 @@ impl<'a> ::buffa::ViewEncode<'a> for FileChangedView<'a> { ); self.diff.write_to(__cache, buf); } + if self.copied_from.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.copied_from.write_to(__cache, buf); + } } } /// Serializes this view as protobuf JSON. @@ -439,6 +493,11 @@ impl<'__a> ::serde::Serialize for FileChangedView<'__a> { __map.serialize_entry("diff", __v)?; } } + { + if let ::core::option::Option::Some(__v) = self.copied_from.as_option() { + __map.serialize_entry("copiedFrom", __v)?; + } + } __map.end() } } @@ -553,7 +612,9 @@ impl FileChangedOwnedView { pub fn change_kind(&self) -> ::buffa::EnumValue { self.0.reborrow().change_kind } - /// Same workspace-relative form as path. + /// Where a renamed file used to be, in the same workspace-relative form as + /// path. Rename only: a copy sets copied_from instead, because a previous path + /// asserts the file is no longer there. /// /// Field 4: `previous_path` #[must_use] @@ -607,6 +668,15 @@ impl FileChangedOwnedView { ) -> &::buffa::MessageFieldView> { &self.0.reborrow().diff } + /// Where the content came from, set only for FILE_CHANGE_KIND_COPIED. + /// + /// Field 10: `copied_from` + #[must_use] + pub fn copied_from( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().copied_from + } } impl ::core::convert::From<::buffa::OwnedView>> for FileChangedOwnedView { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.rs index 0cf07e7eb0..acd37f6286 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.file_changed.rs @@ -38,7 +38,9 @@ pub struct FileChanged { with = "::buffa::json_helpers::proto_enum" )] pub change_kind: ::buffa::EnumValue, - /// Same workspace-relative form as path. + /// Where a renamed file used to be, in the same workspace-relative form as + /// path. Rename only: a copy sets copied_from instead, because a previous path + /// asserts the file is no longer there. /// /// Field 4: `previous_path` #[serde( @@ -97,6 +99,15 @@ pub struct FileChanged { skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" )] pub diff: ::buffa::MessageField>, + /// Where the content came from, set only for FILE_CHANGE_KIND_COPIED. + /// + /// Field 10: `copied_from` + #[serde( + rename = "copiedFrom", + alias = "copied_from", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub copied_from: ::buffa::MessageField>, } impl ::core::fmt::Debug for FileChanged { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -110,6 +121,7 @@ impl ::core::fmt::Debug for FileChanged { .field("tool_call_id", &self.tool_call_id) .field("turn_id", &self.turn_id) .field("diff", &self.diff) + .field("copied_from", &self.copied_from) .finish() } } @@ -187,6 +199,14 @@ impl ::buffa::Message for FileChanged { += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + if self.copied_from.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.copied_from.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } ::buffa::saturate_size(size) } fn write_to( @@ -228,6 +248,14 @@ impl ::buffa::Message for FileChanged { ); self.diff.write_to(__cache, buf); } + if self.copied_from.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.copied_from.write_to(__cache, buf); + } } fn merge_field( &mut self, @@ -322,6 +350,17 @@ impl ::buffa::Message for FileChanged { ctx, )?; } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.copied_from.get_or_insert_default(), + buf, + ctx, + )?; + } _ => { ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } @@ -338,6 +377,7 @@ impl ::buffa::Message for FileChanged { self.tool_call_id.clear(); self.turn_id.clear(); self.diff = ::buffa::MessageField::none(); + self.copied_from = ::buffa::MessageField::none(); } } impl ::buffa::json_helpers::ProtoElemJson for FileChanged { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.__view.rs new file mode 100644 index 0000000000..50fabb757d --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.__view.rs @@ -0,0 +1,545 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fork_session.proto + +/// ForkSession opens a child stream that inherits a prefix of another session's +/// context, recording \[SessionStarted, SessionForked\] as one batch. +/// +/// Write precondition NoStream on the new stream. The source's existence is +/// checked at the command boundary, not by the fold: the source is a different +/// aggregate and this decider never reads it. The plan and workspace are carried +/// rather than inherited for the same reason. +#[derive(Clone, Debug, Default)] +pub struct ForkSessionView<'a> { + /// The new session's own id. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_plan` + pub execution_plan: ::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'a>, + >, + /// Field 3: `workspace` + pub workspace: ::buffa::MessageFieldView< + super::super::__buffa::view::WorkspaceRefView<'a>, + >, + /// Field 4: `source_session_id` + pub source_session_id: &'a str, + /// The source's own ordinal the inherited prefix ends at. + /// + /// Field 5: `context_prefix_boundary` + pub context_prefix_boundary: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 6: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ForkSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_plan` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_plan(&self) -> bool { + self.execution_plan.is_set() + } + /**Whether required field `workspace` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace(&self) -> bool { + self.workspace.is_set() + } + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `context_prefix_boundary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_context_prefix_boundary(&self) -> bool { + self.context_prefix_boundary.is_set() + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ForkSessionView<'a> { + type Owned = super::super::ForkSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.execution_plan.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.execution_plan = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.workspace.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.workspace = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.context_prefix_boundary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.context_prefix_boundary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ForkSession { + session_id: self.session_id.to_string(), + execution_plan: match self.execution_plan.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StoredSessionExecutionPlan, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + workspace: match self.workspace.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::WorkspaceRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_session_id: self.source_session_id.to_string(), + context_prefix_boundary: match self.context_prefix_boundary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ForkSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.context_prefix_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_prefix_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.source_session_id, buf); + if self.context_prefix_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_prefix_boundary.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ForkSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.execution_plan.as_option() { + __map.serialize_entry("executionPlan", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.workspace.as_option() { + __map.serialize_entry("workspace", __v)?; + } + } + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .context_prefix_boundary + .as_option() + { + __map.serialize_entry("contextPrefixBoundary", __v)?; + } + } + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ForkSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ForkSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ForkSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ForkSession"; +} +::buffa::impl_default_view_instance!(ForkSessionView); +::buffa::impl_view_reborrow!(ForkSessionView); +/** Self-contained, `'static` owned view of a `ForkSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`ForkSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ForkSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ForkSessionOwnedView(::buffa::OwnedView>); +impl ForkSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ForkSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ForkSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ForkSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ForkSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ForkSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The new session's own id. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_plan` + #[must_use] + pub fn execution_plan( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'_>, + > { + &self.0.reborrow().execution_plan + } + /// Field 3: `workspace` + #[must_use] + pub fn workspace( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().workspace + } + /// Field 4: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// The source's own ordinal the inherited prefix ends at. + /// + /// Field 5: `context_prefix_boundary` + #[must_use] + pub fn context_prefix_boundary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().context_prefix_boundary + } + /// Field 6: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ForkSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ForkSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ForkSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ForkSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ForkSession { + type View<'a> = ForkSessionView<'a>; + type ViewHandle = ForkSessionOwnedView; +} +impl ::serde::Serialize for ForkSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.rs new file mode 100644 index 0000000000..a342a5adbb --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.fork_session.rs @@ -0,0 +1,260 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/fork_session.proto + +/// ForkSession opens a child stream that inherits a prefix of another session's +/// context, recording \[SessionStarted, SessionForked\] as one batch. +/// +/// Write precondition NoStream on the new stream. The source's existence is +/// checked at the command boundary, not by the fold: the source is a different +/// aggregate and this decider never reads it. The plan and workspace are carried +/// rather than inherited for the same reason. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ForkSession { + /// The new session's own id. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_plan` + #[serde(rename = "executionPlan", alias = "execution_plan")] + pub execution_plan: ::buffa::MessageField< + StoredSessionExecutionPlan, + ::buffa::Inline, + >, + /// Field 3: `workspace` + #[serde(rename = "workspace")] + pub workspace: ::buffa::MessageField>, + /// Field 4: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// The source's own ordinal the inherited prefix ends at. + /// + /// Field 5: `context_prefix_boundary` + #[serde(rename = "contextPrefixBoundary", alias = "context_prefix_boundary")] + pub context_prefix_boundary: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 6: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for ForkSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ForkSession") + .field("session_id", &self.session_id) + .field("execution_plan", &self.execution_plan) + .field("workspace", &self.workspace) + .field("source_session_id", &self.source_session_id) + .field("context_prefix_boundary", &self.context_prefix_boundary) + .field("reason", &self.reason) + .finish() + } +} +impl ForkSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ForkSession"; +} +::buffa::impl_default_instance!(ForkSession); +impl ::buffa::MessageName for ForkSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ForkSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ForkSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ForkSession"; +} +impl ::buffa::Message for ForkSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.context_prefix_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.context_prefix_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.source_session_id, buf); + if self.context_prefix_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.context_prefix_boundary.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(6u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.execution_plan.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.workspace.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.context_prefix_boundary.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_plan = ::buffa::MessageField::none(); + self.workspace = ::buffa::MessageField::none(); + self.source_session_id.clear(); + self.context_prefix_boundary = ::buffa::MessageField::none(); + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ForkSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __FORK_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ForkSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.__view.rs new file mode 100644 index 0000000000..f67cccebdc --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.__view.rs @@ -0,0 +1,287 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/hide_session.proto + +/// HideSession seals a session as hidden, recording \[SessionHidden\]. Hiding is a +/// terminal marker, not a deletion: no bytes are removed (ADR#0035 facet 5). +/// +/// Write precondition At. +#[derive(Clone, Debug, Default)] +pub struct HideSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> HideSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for HideSessionView<'a> { + type Owned = super::super::HideSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::HideSession { + session_id: self.session_id.to_string(), + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for HideSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for HideSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for HideSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "HideSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.HideSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.HideSession"; +} +::buffa::impl_default_view_instance!(HideSessionView); +::buffa::impl_view_reborrow!(HideSessionView); +/** Self-contained, `'static` owned view of a `HideSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`HideSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`HideSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct HideSessionOwnedView(::buffa::OwnedView>); +impl HideSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HideSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HideSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::HideSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + HideSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`HideSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &HideSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::HideSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for HideSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + HideSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: HideSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for HideSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::HideSession { + type View<'a> = HideSessionView<'a>; + type ViewHandle = HideSessionOwnedView; +} +impl ::serde::Serialize for HideSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.rs new file mode 100644 index 0000000000..4bce8c956d --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.hide_session.rs @@ -0,0 +1,132 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/hide_session.proto + +/// HideSession seals a session as hidden, recording \[SessionHidden\]. Hiding is a +/// terminal marker, not a deletion: no bytes are removed (ADR#0035 facet 5). +/// +/// Write precondition At. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct HideSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for HideSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HideSession") + .field("session_id", &self.session_id) + .field("reason", &self.reason) + .finish() + } +} +impl HideSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.HideSession"; +} +::buffa::impl_default_instance!(HideSession); +impl ::buffa::MessageName for HideSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "HideSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.HideSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.HideSession"; +} +impl ::buffa::Message for HideSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for HideSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HIDE_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.HideSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.__view.rs new file mode 100644 index 0000000000..e63a0f550e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.__view.rs @@ -0,0 +1,471 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/mark_execution_attempt_ready.proto + +/// MarkExecutionAttemptReady publishes an attempt's ready attestation, recording +/// \[ExecutionAttemptReady\]. +/// +/// Write precondition At: Ready only after Started, and for a restore only after +/// verified artifact recovery plus effective-tail replay through the start head. +#[derive(Clone, Debug, Default)] +pub struct MarkExecutionAttemptReadyView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_attempt_id` + pub execution_attempt_id: &'a str, + /// Field 3: `ready_attestation_ref` + pub ready_attestation_ref: &'a str, + /// Field 4: `ready_attestation_digest` + pub ready_attestation_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 5: `ready_at` + pub ready_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> MarkExecutionAttemptReadyView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_attempt_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_attempt_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `ready_attestation_ref` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ready_attestation_ref(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `ready_attestation_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ready_attestation_digest(&self) -> bool { + self.ready_attestation_digest.is_set() + } + /**Whether required field `ready_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ready_at(&self) -> bool { + self.ready_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for MarkExecutionAttemptReadyView<'a> { + type Owned = super::super::MarkExecutionAttemptReady; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.execution_attempt_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.ready_attestation_ref = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ready_attestation_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.ready_attestation_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ready_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.ready_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::MarkExecutionAttemptReady, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::MarkExecutionAttemptReady, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::MarkExecutionAttemptReady { + session_id: self.session_id.to_string(), + execution_attempt_id: self.execution_attempt_id.to_string(), + ready_attestation_ref: self.ready_attestation_ref.to_string(), + ready_attestation_digest: match self.ready_attestation_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ready_at: match self.ready_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for MarkExecutionAttemptReadyView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.ready_attestation_ref) as u64; + if self.ready_attestation_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ready_attestation_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.ready_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ready_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + ::buffa::types::put_string_field(3u32, &self.ready_attestation_ref, buf); + if self.ready_attestation_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ready_attestation_digest.write_to(__cache, buf); + } + if self.ready_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ready_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for MarkExecutionAttemptReadyView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("executionAttemptId", self.execution_attempt_id)?; + } + { + __map.serialize_entry("readyAttestationRef", self.ready_attestation_ref)?; + } + { + if let ::core::option::Option::Some(__v) = self + .ready_attestation_digest + .as_option() + { + __map.serialize_entry("readyAttestationDigest", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.ready_at.as_option() { + __map.serialize_entry("readyAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for MarkExecutionAttemptReadyView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "MarkExecutionAttemptReady"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady"; +} +::buffa::impl_default_view_instance!(MarkExecutionAttemptReadyView); +::buffa::impl_view_reborrow!(MarkExecutionAttemptReadyView); +/** Self-contained, `'static` owned view of a `MarkExecutionAttemptReady` message. + + Wraps [`::buffa::OwnedView`]`<`[`MarkExecutionAttemptReadyView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MarkExecutionAttemptReadyView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct MarkExecutionAttemptReadyOwnedView( + ::buffa::OwnedView>, +); +impl MarkExecutionAttemptReadyOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MarkExecutionAttemptReadyOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MarkExecutionAttemptReadyOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::MarkExecutionAttemptReady, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + MarkExecutionAttemptReadyOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`MarkExecutionAttemptReadyView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &MarkExecutionAttemptReadyView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::MarkExecutionAttemptReady { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_attempt_id` + #[must_use] + pub fn execution_attempt_id(&self) -> &'_ str { + self.0.reborrow().execution_attempt_id + } + /// Field 3: `ready_attestation_ref` + #[must_use] + pub fn ready_attestation_ref(&self) -> &'_ str { + self.0.reborrow().ready_attestation_ref + } + /// Field 4: `ready_attestation_digest` + #[must_use] + pub fn ready_attestation_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().ready_attestation_digest + } + /// Field 5: `ready_at` + #[must_use] + pub fn ready_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().ready_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for MarkExecutionAttemptReadyOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + MarkExecutionAttemptReadyOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: MarkExecutionAttemptReadyOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for MarkExecutionAttemptReadyOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::MarkExecutionAttemptReady { + type View<'a> = MarkExecutionAttemptReadyView<'a>; + type ViewHandle = MarkExecutionAttemptReadyOwnedView; +} +impl ::serde::Serialize for MarkExecutionAttemptReadyOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.rs new file mode 100644 index 0000000000..64b1ae2571 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.rs @@ -0,0 +1,221 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/mark_execution_attempt_ready.proto + +/// MarkExecutionAttemptReady publishes an attempt's ready attestation, recording +/// \[ExecutionAttemptReady\]. +/// +/// Write precondition At: Ready only after Started, and for a restore only after +/// verified artifact recovery plus effective-tail replay through the start head. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct MarkExecutionAttemptReady { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_attempt_id` + #[serde( + rename = "executionAttemptId", + alias = "execution_attempt_id", + with = "::buffa::json_helpers::proto_string" + )] + pub execution_attempt_id: ::buffa::alloc::string::String, + /// Field 3: `ready_attestation_ref` + #[serde( + rename = "readyAttestationRef", + alias = "ready_attestation_ref", + with = "::buffa::json_helpers::proto_string" + )] + pub ready_attestation_ref: ::buffa::alloc::string::String, + /// Field 4: `ready_attestation_digest` + #[serde(rename = "readyAttestationDigest", alias = "ready_attestation_digest")] + pub ready_attestation_digest: ::buffa::MessageField>, + /// Field 5: `ready_at` + #[serde(rename = "readyAt", alias = "ready_at")] + pub ready_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for MarkExecutionAttemptReady { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MarkExecutionAttemptReady") + .field("session_id", &self.session_id) + .field("execution_attempt_id", &self.execution_attempt_id) + .field("ready_attestation_ref", &self.ready_attestation_ref) + .field("ready_attestation_digest", &self.ready_attestation_digest) + .field("ready_at", &self.ready_at) + .finish() + } +} +impl MarkExecutionAttemptReady { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady"; +} +::buffa::impl_default_instance!(MarkExecutionAttemptReady); +impl ::buffa::MessageName for MarkExecutionAttemptReady { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "MarkExecutionAttemptReady"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady"; +} +impl ::buffa::Message for MarkExecutionAttemptReady { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.ready_attestation_ref) as u64; + if self.ready_attestation_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ready_attestation_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.ready_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ready_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + ::buffa::types::put_string_field(3u32, &self.ready_attestation_ref, buf); + if self.ready_attestation_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ready_attestation_digest.write_to(__cache, buf); + } + if self.ready_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ready_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.execution_attempt_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.ready_attestation_ref, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.ready_attestation_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.ready_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_attempt_id.clear(); + self.ready_attestation_ref.clear(); + self.ready_attestation_digest = ::buffa::MessageField::none(); + self.ready_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for MarkExecutionAttemptReady { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __MARK_EXECUTION_ATTEMPT_READY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.MarkExecutionAttemptReady", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mod.rs index fe6452d435..8f8fbb9a07 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mod.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.mod.rs @@ -1,6 +1,10 @@ // @generated by buffa-codegen. DO NOT EDIT. +include!("trogonai.session.sessions.v1alpha1.apply_redaction.rs"); +include!("trogonai.session.sessions.v1alpha1.approve_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.archive_session.rs"); include!("trogonai.session.sessions.v1alpha1.digest.rs"); +include!("trogonai.session.sessions.v1alpha1.content_chunks.rs"); include!("trogonai.session.sessions.v1alpha1.artifact.rs"); include!("trogonai.session.sessions.v1alpha1.artifact_erased.rs"); include!("trogonai.session.sessions.v1alpha1.artifact_recorded.rs"); @@ -11,16 +15,39 @@ include!("trogonai.session.sessions.v1alpha1.assistant_message_completed.rs"); include!("trogonai.session.sessions.v1alpha1.assistant_message_failed.rs"); include!("trogonai.session.sessions.v1alpha1.model_settings.rs"); include!("trogonai.session.sessions.v1alpha1.assistant_message_started.rs"); +include!("trogonai.session.sessions.v1alpha1.session_cancelled.rs"); +include!("trogonai.session.sessions.v1alpha1.cancel_session.rs"); include!("trogonai.session.sessions.v1alpha1.cascade_policy.rs"); include!("trogonai.session.sessions.v1alpha1.session_ordinal.rs"); include!("trogonai.session.sessions.v1alpha1.checkpoint.rs"); include!("trogonai.session.sessions.v1alpha1.checkpoint_produced.rs"); +include!("trogonai.session.sessions.v1alpha1.close_session.rs"); +include!("trogonai.session.sessions.v1alpha1.command_output_replay.rs"); include!("trogonai.session.sessions.v1alpha1.command_termination.rs"); include!("trogonai.session.sessions.v1alpha1.compacted.rs"); +include!("trogonai.session.sessions.v1alpha1.compact_session.rs"); +include!("trogonai.session.sessions.v1alpha1.complete_assistant_message.rs"); +include!("trogonai.session.sessions.v1alpha1.detached_work.rs"); +include!("trogonai.session.sessions.v1alpha1.resource_access.rs"); +include!("trogonai.session.sessions.v1alpha1.resource_observation.rs"); +include!("trogonai.session.sessions.v1alpha1.target_outcome.rs"); +include!("trogonai.session.sessions.v1alpha1.complete_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.copy_source.rs"); +include!("trogonai.session.sessions.v1alpha1.execution_plan.rs"); +include!("trogonai.session.sessions.v1alpha1.workspace.rs"); +include!("trogonai.session.sessions.v1alpha1.create_child_session.rs"); +include!("trogonai.session.sessions.v1alpha1.create_session.rs"); include!("trogonai.session.sessions.v1alpha1.delegation_detached.rs"); include!("trogonai.session.sessions.v1alpha1.delegation_dispatched.rs"); +include!("trogonai.session.sessions.v1alpha1.deny_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.detach_delegation.rs"); +include!("trogonai.session.sessions.v1alpha1.detach_parent.rs"); include!("trogonai.session.sessions.v1alpha1.diff_summary.rs"); +include!("trogonai.session.sessions.v1alpha1.dispatch_delegation.rs"); +include!("trogonai.session.sessions.v1alpha1.dispatch_external_delegation.rs"); include!("trogonai.session.sessions.v1alpha1.execution_attempt_ended.rs"); +include!("trogonai.session.sessions.v1alpha1.end_execution_attempt.rs"); +include!("trogonai.session.sessions.v1alpha1.erase_artifact.rs"); include!("trogonai.session.sessions.v1alpha1.execution_attempt_ready.rs"); include!("trogonai.session.sessions.v1alpha1.execution_attempt_started.rs"); include!("trogonai.session.sessions.v1alpha1.external_delegation_dispatched.rs"); @@ -33,23 +60,21 @@ include!("trogonai.session.sessions.v1alpha1.parent_detached.rs"); include!("trogonai.session.sessions.v1alpha1.parent_history_invalidated.rs"); include!("trogonai.session.sessions.v1alpha1.parent_linked.rs"); include!("trogonai.session.sessions.v1alpha1.parent_terminated.rs"); +include!("trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.rs"); include!("trogonai.session.sessions.v1alpha1.redaction_applied.rs"); include!("trogonai.session.sessions.v1alpha1.session_archived.rs"); -include!("trogonai.session.sessions.v1alpha1.session_cancelled.rs"); include!("trogonai.session.sessions.v1alpha1.session_closed.rs"); include!("trogonai.session.sessions.v1alpha1.session_failed.rs"); include!("trogonai.session.sessions.v1alpha1.session_forked.rs"); include!("trogonai.session.sessions.v1alpha1.session_hidden.rs"); +include!("trogonai.session.sessions.v1alpha1.session_recovered.rs"); include!("trogonai.session.sessions.v1alpha1.session_renamed.rs"); include!("trogonai.session.sessions.v1alpha1.session_rewound.rs"); -include!("trogonai.session.sessions.v1alpha1.execution_plan.rs"); -include!("trogonai.session.sessions.v1alpha1.workspace.rs"); include!("trogonai.session.sessions.v1alpha1.session_started.rs"); include!("trogonai.session.sessions.v1alpha1.session_unarchived.rs"); include!("trogonai.session.sessions.v1alpha1.system_notice_recorded.rs"); include!("trogonai.session.sessions.v1alpha1.todo_updated.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_approved.rs"); -include!("trogonai.session.sessions.v1alpha1.resource_observation.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_completed.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_denied.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_failed.rs"); @@ -57,6 +82,33 @@ include!("trogonai.session.sessions.v1alpha1.tool_call_requested.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_started.rs"); include!("trogonai.session.sessions.v1alpha1.user_message_recorded.rs"); include!("trogonai.session.sessions.v1alpha1.events.rs"); +include!("trogonai.session.sessions.v1alpha1.fail_assistant_message.rs"); +include!("trogonai.session.sessions.v1alpha1.fail_session.rs"); +include!("trogonai.session.sessions.v1alpha1.fail_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.fork_session.rs"); +include!("trogonai.session.sessions.v1alpha1.hide_session.rs"); +include!("trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.rs"); +include!("trogonai.session.sessions.v1alpha1.produce_checkpoint.rs"); +include!("trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.rs"); +include!("trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.rs"); +include!("trogonai.session.sessions.v1alpha1.record_artifact.rs"); +include!("trogonai.session.sessions.v1alpha1.record_file_change.rs"); +include!("trogonai.session.sessions.v1alpha1.record_operation_outcome.rs"); +include!("trogonai.session.sessions.v1alpha1.record_system_notice.rs"); +include!("trogonai.session.sessions.v1alpha1.record_user_message.rs"); +include!("trogonai.session.sessions.v1alpha1.recover_session.rs"); +include!("trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.rs"); +include!("trogonai.session.sessions.v1alpha1.rename_session.rs"); +include!("trogonai.session.sessions.v1alpha1.request_operation_cancellation.rs"); +include!("trogonai.session.sessions.v1alpha1.request_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.reserve_operation.rs"); +include!("trogonai.session.sessions.v1alpha1.rewind_session.rs"); +include!("trogonai.session.sessions.v1alpha1.start_assistant_message.rs"); +include!("trogonai.session.sessions.v1alpha1.start_execution_attempt.rs"); +include!("trogonai.session.sessions.v1alpha1.start_tool_call.rs"); +include!("trogonai.session.sessions.v1alpha1.unarchive_session.rs"); +include!("trogonai.session.sessions.v1alpha1.update_todo.rs"); +include!("trogonai.session.sessions.v1alpha1.write_outcome.rs"); #[allow( non_camel_case_types, dead_code, @@ -74,7 +126,11 @@ pub mod __buffa { pub mod view { #[allow(unused_imports)] use super::*; + include!("trogonai.session.sessions.v1alpha1.apply_redaction.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.approve_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.archive_session.__view.rs"); include!("trogonai.session.sessions.v1alpha1.digest.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.content_chunks.__view.rs"); include!("trogonai.session.sessions.v1alpha1.artifact.__view.rs"); include!("trogonai.session.sessions.v1alpha1.artifact_erased.__view.rs"); include!("trogonai.session.sessions.v1alpha1.artifact_recorded.__view.rs"); @@ -91,15 +147,42 @@ pub mod __buffa { include!( "trogonai.session.sessions.v1alpha1.assistant_message_started.__view.rs" ); + include!("trogonai.session.sessions.v1alpha1.session_cancelled.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.cancel_session.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_ordinal.__view.rs"); include!("trogonai.session.sessions.v1alpha1.checkpoint.__view.rs"); include!("trogonai.session.sessions.v1alpha1.checkpoint_produced.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.close_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.command_output_replay.__view.rs"); include!("trogonai.session.sessions.v1alpha1.command_termination.__view.rs"); include!("trogonai.session.sessions.v1alpha1.compacted.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.compact_session.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.complete_assistant_message.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.detached_work.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.resource_access.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.resource_observation.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.target_outcome.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.complete_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.copy_source.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.execution_plan.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.workspace.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.create_child_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.create_session.__view.rs"); include!("trogonai.session.sessions.v1alpha1.delegation_detached.__view.rs"); include!("trogonai.session.sessions.v1alpha1.delegation_dispatched.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.deny_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.detach_delegation.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.detach_parent.__view.rs"); include!("trogonai.session.sessions.v1alpha1.diff_summary.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.dispatch_delegation.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.dispatch_external_delegation.__view.rs" + ); include!("trogonai.session.sessions.v1alpha1.execution_attempt_ended.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.end_execution_attempt.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.erase_artifact.__view.rs"); include!("trogonai.session.sessions.v1alpha1.execution_attempt_ready.__view.rs"); include!( "trogonai.session.sessions.v1alpha1.execution_attempt_started.__view.rs" @@ -121,23 +204,23 @@ pub mod __buffa { ); include!("trogonai.session.sessions.v1alpha1.parent_linked.__view.rs"); include!("trogonai.session.sessions.v1alpha1.parent_terminated.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.__view.rs" + ); include!("trogonai.session.sessions.v1alpha1.redaction_applied.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_archived.__view.rs"); - include!("trogonai.session.sessions.v1alpha1.session_cancelled.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_closed.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_failed.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_forked.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_hidden.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.session_recovered.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_renamed.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_rewound.__view.rs"); - include!("trogonai.session.sessions.v1alpha1.execution_plan.__view.rs"); - include!("trogonai.session.sessions.v1alpha1.workspace.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_started.__view.rs"); include!("trogonai.session.sessions.v1alpha1.session_unarchived.__view.rs"); include!("trogonai.session.sessions.v1alpha1.system_notice_recorded.__view.rs"); include!("trogonai.session.sessions.v1alpha1.todo_updated.__view.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_approved.__view.rs"); - include!("trogonai.session.sessions.v1alpha1.resource_observation.__view.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_completed.__view.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_denied.__view.rs"); include!("trogonai.session.sessions.v1alpha1.tool_call_failed.__view.rs"); @@ -145,6 +228,43 @@ pub mod __buffa { include!("trogonai.session.sessions.v1alpha1.tool_call_started.__view.rs"); include!("trogonai.session.sessions.v1alpha1.user_message_recorded.__view.rs"); include!("trogonai.session.sessions.v1alpha1.events.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.fail_assistant_message.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.fail_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.fail_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.fork_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.hide_session.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.mark_execution_attempt_ready.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.produce_checkpoint.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.record_artifact.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.record_file_change.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.record_operation_outcome.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.record_system_notice.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.record_user_message.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.recover_session.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.rename_session.__view.rs"); + include!( + "trogonai.session.sessions.v1alpha1.request_operation_cancellation.__view.rs" + ); + include!("trogonai.session.sessions.v1alpha1.request_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.reserve_operation.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.rewind_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.start_assistant_message.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.start_execution_attempt.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.start_tool_call.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.unarchive_session.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.update_todo.__view.rs"); + include!("trogonai.session.sessions.v1alpha1.write_outcome.__view.rs"); pub mod oneof { #[allow(unused_imports)] use super::*; @@ -156,12 +276,15 @@ pub mod __buffa { ); include!("trogonai.session.sessions.v1alpha1.compacted.__view_oneof.rs"); include!( - "trogonai.session.sessions.v1alpha1.operation_outcome_recorded.__view_oneof.rs" + "trogonai.session.sessions.v1alpha1.resource_observation.__view_oneof.rs" ); include!( - "trogonai.session.sessions.v1alpha1.resource_observation.__view_oneof.rs" + "trogonai.session.sessions.v1alpha1.operation_outcome_recorded.__view_oneof.rs" ); include!("trogonai.session.sessions.v1alpha1.events.__view_oneof.rs"); + include!( + "trogonai.session.sessions.v1alpha1.record_operation_outcome.__view_oneof.rs" + ); } } pub mod oneof { @@ -172,15 +295,22 @@ pub mod __buffa { include!("trogonai.session.sessions.v1alpha1.message.__oneof.rs"); include!("trogonai.session.sessions.v1alpha1.command_termination.__oneof.rs"); include!("trogonai.session.sessions.v1alpha1.compacted.__oneof.rs"); + include!("trogonai.session.sessions.v1alpha1.resource_observation.__oneof.rs"); include!( "trogonai.session.sessions.v1alpha1.operation_outcome_recorded.__oneof.rs" ); - include!("trogonai.session.sessions.v1alpha1.resource_observation.__oneof.rs"); include!("trogonai.session.sessions.v1alpha1.events.__oneof.rs"); + include!( + "trogonai.session.sessions.v1alpha1.record_operation_outcome.__oneof.rs" + ); } /// Register this package's `Any` type entries and extension entries. pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__APPLY_REDACTION_JSON_ANY); + reg.register_json_any(super::__APPROVE_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__ARCHIVE_SESSION_JSON_ANY); reg.register_json_any(super::__DIGEST_JSON_ANY); + reg.register_json_any(super::__CONTENT_CHUNKS_JSON_ANY); reg.register_json_any(super::__ARTIFACT_REF_JSON_ANY); reg.register_json_any(super::__ARTIFACT_METADATA_JSON_ANY); reg.register_json_any(super::__STORED_ARTIFACT_JSON_ANY); @@ -201,19 +331,46 @@ pub mod __buffa { reg.register_json_any(super::__ASSISTANT_MESSAGE_FAILED_JSON_ANY); reg.register_json_any(super::__MODEL_SETTINGS_JSON_ANY); reg.register_json_any(super::__ASSISTANT_MESSAGE_STARTED_JSON_ANY); + reg.register_json_any(super::__SESSION_CANCELLED_JSON_ANY); + reg.register_json_any(super::__CANCEL_SESSION_JSON_ANY); reg.register_json_any(super::__SESSION_ORDINAL_JSON_ANY); reg.register_json_any(super::__CHECKPOINT_JSON_ANY); reg.register_json_any(super::__CHECKPOINT_PRODUCED_JSON_ANY); + reg.register_json_any(super::__CLOSE_SESSION_JSON_ANY); + reg.register_json_any(super::__COMMAND_OUTPUT_REPLAY_REF_JSON_ANY); + reg.register_json_any(super::__REPLAY_COMPLETENESS_JSON_ANY); reg.register_json_any(super::__COMMAND_TERMINATION_JSON_ANY); reg.register_json_any(super::__COMPACTED_JSON_ANY); reg.register_json_any(super::__COMPACTION_CONTEXT_ROOT_JSON_ANY); reg.register_json_any(super::__COMPACTION_SESSION_START_JSON_ANY); reg.register_json_any(super::__COMPACTION_INHERITED_PREFIX_JSON_ANY); reg.register_json_any(super::__COMPACTION_PRODUCER_JSON_ANY); + reg.register_json_any(super::__COMPACT_SESSION_JSON_ANY); + reg.register_json_any(super::__COMPLETE_ASSISTANT_MESSAGE_JSON_ANY); + reg.register_json_any(super::__DETACHED_WORK_JSON_ANY); + reg.register_json_any(super::__SUPERVISION_POLICY_JSON_ANY); + reg.register_json_any(super::__RESOURCE_ACCESS_RECORD_JSON_ANY); + reg.register_json_any(super::__RESOURCE_OBSERVATION_JSON_ANY); + reg.register_json_any(super::__RESOURCE_ABSENT_JSON_ANY); + reg.register_json_any(super::__BYTE_RANGE_JSON_ANY); + reg.register_json_any(super::__TARGET_OUTCOME_JSON_ANY); + reg.register_json_any(super::__COMPLETE_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__COPY_SOURCE_JSON_ANY); + reg.register_json_any(super::__STORED_SESSION_EXECUTION_PLAN_JSON_ANY); + reg.register_json_any(super::__WORKSPACE_REF_JSON_ANY); + reg.register_json_any(super::__CREATE_CHILD_SESSION_JSON_ANY); + reg.register_json_any(super::__CREATE_SESSION_JSON_ANY); reg.register_json_any(super::__DELEGATION_DETACHED_JSON_ANY); reg.register_json_any(super::__DELEGATION_DISPATCHED_JSON_ANY); + reg.register_json_any(super::__DENY_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__DETACH_DELEGATION_JSON_ANY); + reg.register_json_any(super::__DETACH_PARENT_JSON_ANY); reg.register_json_any(super::__DIFF_SUMMARY_JSON_ANY); + reg.register_json_any(super::__DISPATCH_DELEGATION_JSON_ANY); + reg.register_json_any(super::__DISPATCH_EXTERNAL_DELEGATION_JSON_ANY); reg.register_json_any(super::__EXECUTION_ATTEMPT_ENDED_JSON_ANY); + reg.register_json_any(super::__END_EXECUTION_ATTEMPT_JSON_ANY); + reg.register_json_any(super::__ERASE_ARTIFACT_JSON_ANY); reg.register_json_any(super::__EXECUTION_ATTEMPT_READY_JSON_ANY); reg.register_json_any(super::__EXECUTION_ATTEMPT_STARTED_JSON_ANY); reg.register_json_any(super::__EXTERNAL_DELEGATION_DISPATCHED_JSON_ANY); @@ -229,26 +386,22 @@ pub mod __buffa { reg.register_json_any(super::__PARENT_HISTORY_INVALIDATED_JSON_ANY); reg.register_json_any(super::__PARENT_LINKED_JSON_ANY); reg.register_json_any(super::__PARENT_TERMINATED_JSON_ANY); + reg.register_json_any(super::__PROVIDER_TOOL_INTENT_REJECTED_JSON_ANY); reg.register_json_any(super::__REDACTION_APPLIED_JSON_ANY); reg.register_json_any(super::__SESSION_ARCHIVED_JSON_ANY); - reg.register_json_any(super::__SESSION_CANCELLED_JSON_ANY); reg.register_json_any(super::__SESSION_CLOSED_JSON_ANY); reg.register_json_any(super::__SESSION_FAILED_JSON_ANY); reg.register_json_any(super::__SESSION_FORKED_JSON_ANY); reg.register_json_any(super::__SESSION_HIDDEN_JSON_ANY); + reg.register_json_any(super::__SESSION_RECOVERED_JSON_ANY); reg.register_json_any(super::__SESSION_RENAMED_JSON_ANY); reg.register_json_any(super::__SESSION_REWOUND_JSON_ANY); - reg.register_json_any(super::__STORED_SESSION_EXECUTION_PLAN_JSON_ANY); - reg.register_json_any(super::__WORKSPACE_REF_JSON_ANY); reg.register_json_any(super::__SESSION_STARTED_JSON_ANY); reg.register_json_any(super::__SESSION_UNARCHIVED_JSON_ANY); reg.register_json_any(super::__SYSTEM_NOTICE_RECORDED_JSON_ANY); reg.register_json_any(super::__TODO_UPDATED_JSON_ANY); reg.register_json_any(super::__TODO_ITEM_JSON_ANY); reg.register_json_any(super::__TOOL_CALL_APPROVED_JSON_ANY); - reg.register_json_any(super::__RESOURCE_OBSERVATION_JSON_ANY); - reg.register_json_any(super::__RESOURCE_ABSENT_JSON_ANY); - reg.register_json_any(super::__BYTE_RANGE_JSON_ANY); reg.register_json_any(super::__TOOL_CALL_COMPLETED_JSON_ANY); reg.register_json_any(super::__TOOL_CALL_DENIED_JSON_ANY); reg.register_json_any(super::__TOOL_CALL_FAILED_JSON_ANY); @@ -256,13 +409,58 @@ pub mod __buffa { reg.register_json_any(super::__TOOL_CALL_STARTED_JSON_ANY); reg.register_json_any(super::__USER_MESSAGE_RECORDED_JSON_ANY); reg.register_json_any(super::__SESSION_EVENT_JSON_ANY); + reg.register_json_any(super::__FAIL_ASSISTANT_MESSAGE_JSON_ANY); + reg.register_json_any(super::__FAIL_SESSION_JSON_ANY); + reg.register_json_any(super::__FAIL_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__FORK_SESSION_JSON_ANY); + reg.register_json_any(super::__HIDE_SESSION_JSON_ANY); + reg.register_json_any(super::__MARK_EXECUTION_ATTEMPT_READY_JSON_ANY); + reg.register_json_any(super::__PRODUCE_CHECKPOINT_JSON_ANY); + reg.register_json_any(super::__RECONCILE_PARENT_REWIND_JSON_ANY); + reg.register_json_any(super::__RECONCILE_PARENT_TERMINAL_JSON_ANY); + reg.register_json_any(super::__RECORD_ARTIFACT_JSON_ANY); + reg.register_json_any(super::__RECORD_FILE_CHANGE_JSON_ANY); + reg.register_json_any(super::__RECORD_OPERATION_OUTCOME_JSON_ANY); + reg.register_json_any(super::__RECORD_SYSTEM_NOTICE_JSON_ANY); + reg.register_json_any(super::__RECORD_USER_MESSAGE_JSON_ANY); + reg.register_json_any(super::__RECOVER_SESSION_JSON_ANY); + reg.register_json_any(super::__REJECT_PROVIDER_TOOL_INTENT_JSON_ANY); + reg.register_json_any(super::__RENAME_SESSION_JSON_ANY); + reg.register_json_any(super::__REQUEST_OPERATION_CANCELLATION_JSON_ANY); + reg.register_json_any(super::__REQUEST_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__RESERVE_OPERATION_JSON_ANY); + reg.register_json_any(super::__REWIND_SESSION_JSON_ANY); + reg.register_json_any(super::__START_ASSISTANT_MESSAGE_JSON_ANY); + reg.register_json_any(super::__START_EXECUTION_ATTEMPT_JSON_ANY); + reg.register_json_any(super::__START_TOOL_CALL_JSON_ANY); + reg.register_json_any(super::__UNARCHIVE_SESSION_JSON_ANY); + reg.register_json_any(super::__UPDATE_TODO_JSON_ANY); + reg.register_json_any(super::__WRITE_OUTCOME_JSON_ANY); + reg.register_json_any(super::__INDETERMINATE_WRITE_JSON_ANY); + reg.register_json_any(super::__WRITE_CONFLICT_JSON_ANY); } } #[doc(inline)] +pub use self::__buffa::view::ApplyRedactionView; +#[doc(inline)] +pub use self::__buffa::view::ApplyRedactionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ApproveToolCallView; +#[doc(inline)] +pub use self::__buffa::view::ApproveToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ArchiveSessionView; +#[doc(inline)] +pub use self::__buffa::view::ArchiveSessionOwnedView; +#[doc(inline)] pub use self::__buffa::view::DigestView; #[doc(inline)] pub use self::__buffa::view::DigestOwnedView; #[doc(inline)] +pub use self::__buffa::view::ContentChunksView; +#[doc(inline)] +pub use self::__buffa::view::ContentChunksOwnedView; +#[doc(inline)] pub use self::__buffa::view::ArtifactRefView; #[doc(inline)] pub use self::__buffa::view::ArtifactRefOwnedView; @@ -343,6 +541,14 @@ pub use self::__buffa::view::AssistantMessageStartedView; #[doc(inline)] pub use self::__buffa::view::AssistantMessageStartedOwnedView; #[doc(inline)] +pub use self::__buffa::view::SessionCancelledView; +#[doc(inline)] +pub use self::__buffa::view::SessionCancelledOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CancelSessionView; +#[doc(inline)] +pub use self::__buffa::view::CancelSessionOwnedView; +#[doc(inline)] pub use self::__buffa::view::SessionOrdinalView; #[doc(inline)] pub use self::__buffa::view::SessionOrdinalOwnedView; @@ -355,6 +561,18 @@ pub use self::__buffa::view::CheckpointProducedView; #[doc(inline)] pub use self::__buffa::view::CheckpointProducedOwnedView; #[doc(inline)] +pub use self::__buffa::view::CloseSessionView; +#[doc(inline)] +pub use self::__buffa::view::CloseSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CommandOutputReplayRefView; +#[doc(inline)] +pub use self::__buffa::view::CommandOutputReplayRefOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReplayCompletenessView; +#[doc(inline)] +pub use self::__buffa::view::ReplayCompletenessOwnedView; +#[doc(inline)] pub use self::__buffa::view::CommandTerminationView; #[doc(inline)] pub use self::__buffa::view::CommandTerminationOwnedView; @@ -379,6 +597,66 @@ pub use self::__buffa::view::CompactionProducerView; #[doc(inline)] pub use self::__buffa::view::CompactionProducerOwnedView; #[doc(inline)] +pub use self::__buffa::view::CompactSessionView; +#[doc(inline)] +pub use self::__buffa::view::CompactSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CompleteAssistantMessageView; +#[doc(inline)] +pub use self::__buffa::view::CompleteAssistantMessageOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DetachedWorkView; +#[doc(inline)] +pub use self::__buffa::view::DetachedWorkOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SupervisionPolicyView; +#[doc(inline)] +pub use self::__buffa::view::SupervisionPolicyOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ResourceAccessRecordView; +#[doc(inline)] +pub use self::__buffa::view::ResourceAccessRecordOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ResourceObservationView; +#[doc(inline)] +pub use self::__buffa::view::ResourceObservationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ResourceAbsentView; +#[doc(inline)] +pub use self::__buffa::view::ResourceAbsentOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ByteRangeView; +#[doc(inline)] +pub use self::__buffa::view::ByteRangeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::TargetOutcomeView; +#[doc(inline)] +pub use self::__buffa::view::TargetOutcomeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CompleteToolCallView; +#[doc(inline)] +pub use self::__buffa::view::CompleteToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CopySourceView; +#[doc(inline)] +pub use self::__buffa::view::CopySourceOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StoredSessionExecutionPlanView; +#[doc(inline)] +pub use self::__buffa::view::StoredSessionExecutionPlanOwnedView; +#[doc(inline)] +pub use self::__buffa::view::WorkspaceRefView; +#[doc(inline)] +pub use self::__buffa::view::WorkspaceRefOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CreateChildSessionView; +#[doc(inline)] +pub use self::__buffa::view::CreateChildSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::CreateSessionView; +#[doc(inline)] +pub use self::__buffa::view::CreateSessionOwnedView; +#[doc(inline)] pub use self::__buffa::view::DelegationDetachedView; #[doc(inline)] pub use self::__buffa::view::DelegationDetachedOwnedView; @@ -387,14 +665,42 @@ pub use self::__buffa::view::DelegationDispatchedView; #[doc(inline)] pub use self::__buffa::view::DelegationDispatchedOwnedView; #[doc(inline)] +pub use self::__buffa::view::DenyToolCallView; +#[doc(inline)] +pub use self::__buffa::view::DenyToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DetachDelegationView; +#[doc(inline)] +pub use self::__buffa::view::DetachDelegationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DetachParentView; +#[doc(inline)] +pub use self::__buffa::view::DetachParentOwnedView; +#[doc(inline)] pub use self::__buffa::view::DiffSummaryView; #[doc(inline)] pub use self::__buffa::view::DiffSummaryOwnedView; #[doc(inline)] +pub use self::__buffa::view::DispatchDelegationView; +#[doc(inline)] +pub use self::__buffa::view::DispatchDelegationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::DispatchExternalDelegationView; +#[doc(inline)] +pub use self::__buffa::view::DispatchExternalDelegationOwnedView; +#[doc(inline)] pub use self::__buffa::view::ExecutionAttemptEndedView; #[doc(inline)] pub use self::__buffa::view::ExecutionAttemptEndedOwnedView; #[doc(inline)] +pub use self::__buffa::view::EndExecutionAttemptView; +#[doc(inline)] +pub use self::__buffa::view::EndExecutionAttemptOwnedView; +#[doc(inline)] +pub use self::__buffa::view::EraseArtifactView; +#[doc(inline)] +pub use self::__buffa::view::EraseArtifactOwnedView; +#[doc(inline)] pub use self::__buffa::view::ExecutionAttemptReadyView; #[doc(inline)] pub use self::__buffa::view::ExecutionAttemptReadyOwnedView; @@ -455,6 +761,10 @@ pub use self::__buffa::view::ParentTerminatedView; #[doc(inline)] pub use self::__buffa::view::ParentTerminatedOwnedView; #[doc(inline)] +pub use self::__buffa::view::ProviderToolIntentRejectedView; +#[doc(inline)] +pub use self::__buffa::view::ProviderToolIntentRejectedOwnedView; +#[doc(inline)] pub use self::__buffa::view::RedactionAppliedView; #[doc(inline)] pub use self::__buffa::view::RedactionAppliedOwnedView; @@ -463,10 +773,6 @@ pub use self::__buffa::view::SessionArchivedView; #[doc(inline)] pub use self::__buffa::view::SessionArchivedOwnedView; #[doc(inline)] -pub use self::__buffa::view::SessionCancelledView; -#[doc(inline)] -pub use self::__buffa::view::SessionCancelledOwnedView; -#[doc(inline)] pub use self::__buffa::view::SessionClosedView; #[doc(inline)] pub use self::__buffa::view::SessionClosedOwnedView; @@ -483,6 +789,10 @@ pub use self::__buffa::view::SessionHiddenView; #[doc(inline)] pub use self::__buffa::view::SessionHiddenOwnedView; #[doc(inline)] +pub use self::__buffa::view::SessionRecoveredView; +#[doc(inline)] +pub use self::__buffa::view::SessionRecoveredOwnedView; +#[doc(inline)] pub use self::__buffa::view::SessionRenamedView; #[doc(inline)] pub use self::__buffa::view::SessionRenamedOwnedView; @@ -491,14 +801,6 @@ pub use self::__buffa::view::SessionRewoundView; #[doc(inline)] pub use self::__buffa::view::SessionRewoundOwnedView; #[doc(inline)] -pub use self::__buffa::view::StoredSessionExecutionPlanView; -#[doc(inline)] -pub use self::__buffa::view::StoredSessionExecutionPlanOwnedView; -#[doc(inline)] -pub use self::__buffa::view::WorkspaceRefView; -#[doc(inline)] -pub use self::__buffa::view::WorkspaceRefOwnedView; -#[doc(inline)] pub use self::__buffa::view::SessionStartedView; #[doc(inline)] pub use self::__buffa::view::SessionStartedOwnedView; @@ -523,18 +825,6 @@ pub use self::__buffa::view::ToolCallApprovedView; #[doc(inline)] pub use self::__buffa::view::ToolCallApprovedOwnedView; #[doc(inline)] -pub use self::__buffa::view::ResourceObservationView; -#[doc(inline)] -pub use self::__buffa::view::ResourceObservationOwnedView; -#[doc(inline)] -pub use self::__buffa::view::ResourceAbsentView; -#[doc(inline)] -pub use self::__buffa::view::ResourceAbsentOwnedView; -#[doc(inline)] -pub use self::__buffa::view::ByteRangeView; -#[doc(inline)] -pub use self::__buffa::view::ByteRangeOwnedView; -#[doc(inline)] pub use self::__buffa::view::ToolCallCompletedView; #[doc(inline)] pub use self::__buffa::view::ToolCallCompletedOwnedView; @@ -563,4 +853,120 @@ pub use self::__buffa::view::SessionEventView; #[doc(inline)] pub use self::__buffa::view::SessionEventOwnedView; #[doc(inline)] +pub use self::__buffa::view::FailAssistantMessageView; +#[doc(inline)] +pub use self::__buffa::view::FailAssistantMessageOwnedView; +#[doc(inline)] +pub use self::__buffa::view::FailSessionView; +#[doc(inline)] +pub use self::__buffa::view::FailSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::FailToolCallView; +#[doc(inline)] +pub use self::__buffa::view::FailToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ForkSessionView; +#[doc(inline)] +pub use self::__buffa::view::ForkSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::HideSessionView; +#[doc(inline)] +pub use self::__buffa::view::HideSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::MarkExecutionAttemptReadyView; +#[doc(inline)] +pub use self::__buffa::view::MarkExecutionAttemptReadyOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ProduceCheckpointView; +#[doc(inline)] +pub use self::__buffa::view::ProduceCheckpointOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileParentRewindView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileParentRewindOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileParentTerminalView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileParentTerminalOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecordArtifactView; +#[doc(inline)] +pub use self::__buffa::view::RecordArtifactOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecordFileChangeView; +#[doc(inline)] +pub use self::__buffa::view::RecordFileChangeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecordOperationOutcomeView; +#[doc(inline)] +pub use self::__buffa::view::RecordOperationOutcomeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecordSystemNoticeView; +#[doc(inline)] +pub use self::__buffa::view::RecordSystemNoticeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecordUserMessageView; +#[doc(inline)] +pub use self::__buffa::view::RecordUserMessageOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RecoverSessionView; +#[doc(inline)] +pub use self::__buffa::view::RecoverSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RejectProviderToolIntentView; +#[doc(inline)] +pub use self::__buffa::view::RejectProviderToolIntentOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RenameSessionView; +#[doc(inline)] +pub use self::__buffa::view::RenameSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RequestOperationCancellationView; +#[doc(inline)] +pub use self::__buffa::view::RequestOperationCancellationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RequestToolCallView; +#[doc(inline)] +pub use self::__buffa::view::RequestToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReserveOperationView; +#[doc(inline)] +pub use self::__buffa::view::ReserveOperationOwnedView; +#[doc(inline)] +pub use self::__buffa::view::RewindSessionView; +#[doc(inline)] +pub use self::__buffa::view::RewindSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StartAssistantMessageView; +#[doc(inline)] +pub use self::__buffa::view::StartAssistantMessageOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StartExecutionAttemptView; +#[doc(inline)] +pub use self::__buffa::view::StartExecutionAttemptOwnedView; +#[doc(inline)] +pub use self::__buffa::view::StartToolCallView; +#[doc(inline)] +pub use self::__buffa::view::StartToolCallOwnedView; +#[doc(inline)] +pub use self::__buffa::view::UnarchiveSessionView; +#[doc(inline)] +pub use self::__buffa::view::UnarchiveSessionOwnedView; +#[doc(inline)] +pub use self::__buffa::view::UpdateTodoView; +#[doc(inline)] +pub use self::__buffa::view::UpdateTodoOwnedView; +#[doc(inline)] +pub use self::__buffa::view::WriteOutcomeView; +#[doc(inline)] +pub use self::__buffa::view::WriteOutcomeOwnedView; +#[doc(inline)] +pub use self::__buffa::view::IndeterminateWriteView; +#[doc(inline)] +pub use self::__buffa::view::IndeterminateWriteOwnedView; +#[doc(inline)] +pub use self::__buffa::view::WriteConflictView; +#[doc(inline)] +pub use self::__buffa::view::WriteConflictOwnedView; +#[doc(inline)] pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.__view.rs new file mode 100644 index 0000000000..dfa6908340 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.__view.rs @@ -0,0 +1,336 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/produce_checkpoint.proto + +/// ProduceCheckpoint records opaque durable state an execution attempt captured +/// mid-run, recording \[CheckpointProduced\], so a later attempt can restore it +/// instead of replaying from the beginning. +/// +/// Write precondition Any: the first evidence admitted per checkpoint_id wins; a +/// later event reusing the id stays on the log but never replaces it, so a +/// restore always resolves to the same bytes. +#[derive(Clone, Debug, Default)] +pub struct ProduceCheckpointView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Self-describing: checkpoint id, producing attempt, covered boundary, + /// and the execution plan digest it is bound to all live here. + /// + /// Field 2: `checkpoint` + pub checkpoint: ::buffa::MessageFieldView< + super::super::__buffa::view::CheckpointView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProduceCheckpointView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `checkpoint` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_checkpoint(&self) -> bool { + self.checkpoint.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ProduceCheckpointView<'a> { + type Owned = super::super::ProduceCheckpoint; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.checkpoint.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.checkpoint = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProduceCheckpoint { + session_id: self.session_id.to_string(), + checkpoint: match self.checkpoint.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Checkpoint, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProduceCheckpointView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.checkpoint.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProduceCheckpointView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.checkpoint.as_option() { + __map.serialize_entry("checkpoint", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProduceCheckpointView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ProduceCheckpoint"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ProduceCheckpoint"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProduceCheckpoint"; +} +::buffa::impl_default_view_instance!(ProduceCheckpointView); +::buffa::impl_view_reborrow!(ProduceCheckpointView); +/** Self-contained, `'static` owned view of a `ProduceCheckpoint` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProduceCheckpointView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProduceCheckpointView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProduceCheckpointOwnedView( + ::buffa::OwnedView>, +); +impl ProduceCheckpointOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProduceCheckpointOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProduceCheckpointOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProduceCheckpoint, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProduceCheckpointOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProduceCheckpointView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProduceCheckpointView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProduceCheckpoint { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Self-describing: checkpoint id, producing attempt, covered boundary, + /// and the execution plan digest it is bound to all live here. + /// + /// Field 2: `checkpoint` + #[must_use] + pub fn checkpoint( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().checkpoint + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProduceCheckpointOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ProduceCheckpointOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProduceCheckpointOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProduceCheckpointOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProduceCheckpoint { + type View<'a> = ProduceCheckpointView<'a>; + type ViewHandle = ProduceCheckpointOwnedView; +} +impl ::serde::Serialize for ProduceCheckpointOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.rs new file mode 100644 index 0000000000..0c8206ded1 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.produce_checkpoint.rs @@ -0,0 +1,151 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/produce_checkpoint.proto + +/// ProduceCheckpoint records opaque durable state an execution attempt captured +/// mid-run, recording \[CheckpointProduced\], so a later attempt can restore it +/// instead of replaying from the beginning. +/// +/// Write precondition Any: the first evidence admitted per checkpoint_id wins; a +/// later event reusing the id stays on the log but never replaces it, so a +/// restore always resolves to the same bytes. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProduceCheckpoint { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Self-describing: checkpoint id, producing attempt, covered boundary, + /// and the execution plan digest it is bound to all live here. + /// + /// Field 2: `checkpoint` + #[serde(rename = "checkpoint")] + pub checkpoint: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for ProduceCheckpoint { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProduceCheckpoint") + .field("session_id", &self.session_id) + .field("checkpoint", &self.checkpoint) + .finish() + } +} +impl ProduceCheckpoint { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProduceCheckpoint"; +} +::buffa::impl_default_instance!(ProduceCheckpoint); +impl ::buffa::MessageName for ProduceCheckpoint { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ProduceCheckpoint"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ProduceCheckpoint"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProduceCheckpoint"; +} +impl ::buffa::Message for ProduceCheckpoint { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.checkpoint.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.checkpoint.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.checkpoint = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProduceCheckpoint { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PRODUCE_CHECKPOINT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProduceCheckpoint", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.__view.rs new file mode 100644 index 0000000000..5c9ec4fa0e --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.__view.rs @@ -0,0 +1,600 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto + +/// ProviderToolIntentRejected records that a provider emitted something shaped +/// like a tool call which the runtime refused to turn into one. +/// +/// It exists because the malformed intent structurally cannot be stored anywhere +/// else. The canonical transcript form is `ToolUseBlock`, whose `input_json` is +/// LEGACY_REQUIRED and must be valid JSON; an intent whose arguments are truncated +/// JSON has nothing to put there. `ProviderBlock` retains the raw payload but is +/// documented write-verbatim, read-never, so mining it for diagnosis would make a +/// projection depend on a shape the domain promised never to interpret. The +/// choice is therefore a typed event or nothing, and nothing means the most +/// common provider fault in production leaves a session that simply did less than +/// it appeared to. +/// +/// This is not ToolCallDenied. Denial is a well-formed request a human, policy, +/// or hook refused, and the request exists. Here no request was ever admissible, +/// so no ToolCallRequested is written, no execution id is minted, and no +/// operation is reserved. Refusing to synthesize a request out of unparseable +/// input is the whole point: a synthetic ToolCallRequested would put a call on the +/// log that the provider never validly asked for. +/// +/// It is per-intent and not per-message. A message carrying nine sound tool calls +/// and one malformed one must keep the nine, so the sound calls proceed to +/// ToolCallRequested normally while only the tenth lands here. Marking the whole +/// assistant message failed would discard nine calls to describe one. +/// +/// It is a commuting happened-fact (WRITE_PRECONDITION = Any, ADR#0035 facet 2). +/// It records something the provider already did; nothing about the session's +/// current lifecycle can make it untrue. +#[derive(Clone, Debug, Default)] +pub struct ProviderToolIntentRejectedView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Identifies this rejection. Minted by the runtime, because the whole class of + /// fault is that the provider's own identifier is missing, empty, or duplicated + /// and cannot be used as a key. + /// + /// Field 2: `rejection_id` + pub rejection_id: &'a str, + /// The assistant message this intent arrived in (CanonicalMessage.message_id). + /// + /// Field 3: `message_id` + pub message_id: &'a str, + /// Turn this generation belongs to (see UserMessageRecorded.turn_id). + /// + /// Field 4: `turn_id` + pub turn_id: &'a str, + /// Field 5: `reason` + pub reason: ::buffa::EnumValue, + /// What the provider claimed the call's id was, verbatim, including empty when + /// that was the fault. Recorded as a claim rather than as an identity: it may + /// be empty, may collide with a real call, and must never be joined against + /// tool_call_id anywhere. + /// + /// Field 6: `claimed_tool_call_id` + pub claimed_tool_call_id: ::core::option::Option<&'a str>, + /// What the provider claimed the tool's name was, verbatim. Empty when absent. + /// + /// Field 7: `claimed_tool_name` + pub claimed_tool_name: ::core::option::Option<&'a str>, + /// Claim-check to the provider's raw emission for this intent. + /// + /// Out of line rather than inline for the reason every other unbounded payload + /// is: malformed input has no length bound, and this particular payload is the + /// one shaped by whatever produced the fault. A megabyte of truncated JSON + /// inlined into a never-truncated log is a way to make one bad generation + /// permanent for every reader of the stream. + /// + /// Unset when the raw emission could not be captured, which is itself worth + /// distinguishing from a capture of nothing. + /// + /// Field 8: `raw_intent` + pub raw_intent: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + /// Free-text detail from the parser or validator, for humans. Never parsed. + /// + /// Field 9: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProviderToolIntentRejectedView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `rejection_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_rejection_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `message_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ProviderToolIntentRejectedView<'a> { + type Owned = super::super::ProviderToolIntentRejected; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.rejection_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.claimed_tool_call_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.claimed_tool_name = Some(::buffa::types::borrow_str(&mut cur)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.raw_intent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.raw_intent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ProviderToolIntentRejected, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ProviderToolIntentRejected, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProviderToolIntentRejected { + session_id: self.session_id.to_string(), + rejection_id: self.rejection_id.to_string(), + message_id: self.message_id.to_string(), + turn_id: self.turn_id.to_string(), + reason: self.reason, + claimed_tool_call_id: self.claimed_tool_call_id.map(|s| s.to_string()), + claimed_tool_name: self.claimed_tool_name.map(|s| s.to_string()), + raw_intent: match self.raw_intent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProviderToolIntentRejectedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.rejection_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.claimed_tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.claimed_tool_name { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.raw_intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.rejection_id, buf); + ::buffa::types::put_string_field(3u32, &self.message_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.claimed_tool_call_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.claimed_tool_name { + ::buffa::types::put_string_field(7u32, v, buf); + } + if self.raw_intent.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.raw_intent.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(9u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProviderToolIntentRejectedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("rejectionId", self.rejection_id)?; + } + { + __map.serialize_entry("messageId", self.message_id)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.claimed_tool_call_id { + __map.serialize_entry("claimedToolCallId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.claimed_tool_name { + __map.serialize_entry("claimedToolName", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.raw_intent.as_option() { + __map.serialize_entry("rawIntent", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProviderToolIntentRejectedView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ProviderToolIntentRejected"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected"; +} +::buffa::impl_default_view_instance!(ProviderToolIntentRejectedView); +::buffa::impl_view_reborrow!(ProviderToolIntentRejectedView); +/** Self-contained, `'static` owned view of a `ProviderToolIntentRejected` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProviderToolIntentRejectedView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProviderToolIntentRejectedView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProviderToolIntentRejectedOwnedView( + ::buffa::OwnedView>, +); +impl ProviderToolIntentRejectedOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderToolIntentRejectedOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderToolIntentRejectedOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProviderToolIntentRejected, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderToolIntentRejectedOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProviderToolIntentRejectedView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProviderToolIntentRejectedView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProviderToolIntentRejected { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Identifies this rejection. Minted by the runtime, because the whole class of + /// fault is that the provider's own identifier is missing, empty, or duplicated + /// and cannot be used as a key. + /// + /// Field 2: `rejection_id` + #[must_use] + pub fn rejection_id(&self) -> &'_ str { + self.0.reborrow().rejection_id + } + /// The assistant message this intent arrived in (CanonicalMessage.message_id). + /// + /// Field 3: `message_id` + #[must_use] + pub fn message_id(&self) -> &'_ str { + self.0.reborrow().message_id + } + /// Turn this generation belongs to (see UserMessageRecorded.turn_id). + /// + /// Field 4: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 5: `reason` + #[must_use] + pub fn reason( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// What the provider claimed the call's id was, verbatim, including empty when + /// that was the fault. Recorded as a claim rather than as an identity: it may + /// be empty, may collide with a real call, and must never be joined against + /// tool_call_id anywhere. + /// + /// Field 6: `claimed_tool_call_id` + #[must_use] + pub fn claimed_tool_call_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().claimed_tool_call_id + } + /// What the provider claimed the tool's name was, verbatim. Empty when absent. + /// + /// Field 7: `claimed_tool_name` + #[must_use] + pub fn claimed_tool_name(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().claimed_tool_name + } + /// Claim-check to the provider's raw emission for this intent. + /// + /// Out of line rather than inline for the reason every other unbounded payload + /// is: malformed input has no length bound, and this particular payload is the + /// one shaped by whatever produced the fault. A megabyte of truncated JSON + /// inlined into a never-truncated log is a way to make one bad generation + /// permanent for every reader of the stream. + /// + /// Unset when the raw emission could not be captured, which is itself worth + /// distinguishing from a capture of nothing. + /// + /// Field 8: `raw_intent` + #[must_use] + pub fn raw_intent( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().raw_intent + } + /// Free-text detail from the parser or validator, for humans. Never parsed. + /// + /// Field 9: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProviderToolIntentRejectedOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ProviderToolIntentRejectedOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProviderToolIntentRejectedOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProviderToolIntentRejectedOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProviderToolIntentRejected { + type View<'a> = ProviderToolIntentRejectedView<'a>; + type ViewHandle = ProviderToolIntentRejectedOwnedView; +} +impl ::serde::Serialize for ProviderToolIntentRejectedOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.rs new file mode 100644 index 0000000000..027d8403d5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.provider_tool_intent_rejected.rs @@ -0,0 +1,672 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/provider_tool_intent_rejected.proto + +/// ProviderToolIntentRejectionReason is why the intent was not admissible. +/// +/// The reasons are typed because the operational responses differ: a malformed +/// argument payload is a prompt or model problem, an unknown tool name is a +/// catalog drift problem, and a duplicate id is a provider bug that will corrupt +/// joins if it is ever admitted. A single free-text reason makes those one alert. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ProviderToolIntentRejectionReason { + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED = 0i32, + /// Arguments were not parseable as JSON, or parsed to something that is not an + /// object. + PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS = 1i32, + /// Arguments parsed but did not satisfy the tool's declared input schema. + PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION = 2i32, + /// The provider supplied no call id, or an empty one. + PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID = 3i32, + /// The call id collides with one already used in this session. Refused rather + /// than deduplicated: admitting it would make the result of one call + /// attributable to another, and every downstream join silently wrong. + PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID = 4i32, + /// No tool name, or a name no registered tool answers to. + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL = 5i32, + /// The intent named a parent tool use that does not exist in this session, so + /// its position in the call tree is unresolvable. + PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT = 6i32, + /// The emission exceeded the runtime's accepted size for a single intent and + /// was refused before parsing. + PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED = 7i32, +} +impl ProviderToolIntentRejectionReason { + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MalformedArguments: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const SchemaViolation: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const MissingCallId: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DuplicateCallId: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnknownTool: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnresolvableParent: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT; + ///Idiomatic alias for [`Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Oversized: Self = Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED; +} +impl ::core::default::Default for ProviderToolIntentRejectionReason { + fn default() -> Self { + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for ProviderToolIntentRejectionReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ProviderToolIntentRejectionReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ProviderToolIntentRejectionReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ProviderToolIntentRejectionReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name( + v, + ) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32( + v32, + ) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32( + v32, + ) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProviderToolIntentRejectionReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ProviderToolIntentRejectionReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED, + ) + } + 1i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS, + ) + } + 2i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID, + ) + } + 5i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL, + ) + } + 6i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT, + ) + } + 7i32 => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT" + } + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED => { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT, + ) + } + "PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED" => { + ::core::option::Option::Some( + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNSPECIFIED, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MALFORMED_ARGUMENTS, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_SCHEMA_VIOLATION, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_MISSING_CALL_ID, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_DUPLICATE_CALL_ID, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNKNOWN_TOOL, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_UNRESOLVABLE_PARENT, + Self::PROVIDER_TOOL_INTENT_REJECTION_REASON_OVERSIZED, + ] + } +} +/// ProviderToolIntentRejected records that a provider emitted something shaped +/// like a tool call which the runtime refused to turn into one. +/// +/// It exists because the malformed intent structurally cannot be stored anywhere +/// else. The canonical transcript form is `ToolUseBlock`, whose `input_json` is +/// LEGACY_REQUIRED and must be valid JSON; an intent whose arguments are truncated +/// JSON has nothing to put there. `ProviderBlock` retains the raw payload but is +/// documented write-verbatim, read-never, so mining it for diagnosis would make a +/// projection depend on a shape the domain promised never to interpret. The +/// choice is therefore a typed event or nothing, and nothing means the most +/// common provider fault in production leaves a session that simply did less than +/// it appeared to. +/// +/// This is not ToolCallDenied. Denial is a well-formed request a human, policy, +/// or hook refused, and the request exists. Here no request was ever admissible, +/// so no ToolCallRequested is written, no execution id is minted, and no +/// operation is reserved. Refusing to synthesize a request out of unparseable +/// input is the whole point: a synthetic ToolCallRequested would put a call on the +/// log that the provider never validly asked for. +/// +/// It is per-intent and not per-message. A message carrying nine sound tool calls +/// and one malformed one must keep the nine, so the sound calls proceed to +/// ToolCallRequested normally while only the tenth lands here. Marking the whole +/// assistant message failed would discard nine calls to describe one. +/// +/// It is a commuting happened-fact (WRITE_PRECONDITION = Any, ADR#0035 facet 2). +/// It records something the provider already did; nothing about the session's +/// current lifecycle can make it untrue. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProviderToolIntentRejected { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Identifies this rejection. Minted by the runtime, because the whole class of + /// fault is that the provider's own identifier is missing, empty, or duplicated + /// and cannot be used as a key. + /// + /// Field 2: `rejection_id` + #[serde( + rename = "rejectionId", + alias = "rejection_id", + with = "::buffa::json_helpers::proto_string" + )] + pub rejection_id: ::buffa::alloc::string::String, + /// The assistant message this intent arrived in (CanonicalMessage.message_id). + /// + /// Field 3: `message_id` + #[serde( + rename = "messageId", + alias = "message_id", + with = "::buffa::json_helpers::proto_string" + )] + pub message_id: ::buffa::alloc::string::String, + /// Turn this generation belongs to (see UserMessageRecorded.turn_id). + /// + /// Field 4: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 5: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// What the provider claimed the call's id was, verbatim, including empty when + /// that was the fault. Recorded as a claim rather than as an identity: it may + /// be empty, may collide with a real call, and must never be joined against + /// tool_call_id anywhere. + /// + /// Field 6: `claimed_tool_call_id` + #[serde( + rename = "claimedToolCallId", + alias = "claimed_tool_call_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub claimed_tool_call_id: ::core::option::Option<::buffa::alloc::string::String>, + /// What the provider claimed the tool's name was, verbatim. Empty when absent. + /// + /// Field 7: `claimed_tool_name` + #[serde( + rename = "claimedToolName", + alias = "claimed_tool_name", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub claimed_tool_name: ::core::option::Option<::buffa::alloc::string::String>, + /// Claim-check to the provider's raw emission for this intent. + /// + /// Out of line rather than inline for the reason every other unbounded payload + /// is: malformed input has no length bound, and this particular payload is the + /// one shaped by whatever produced the fault. A megabyte of truncated JSON + /// inlined into a never-truncated log is a way to make one bad generation + /// permanent for every reader of the stream. + /// + /// Unset when the raw emission could not be captured, which is itself worth + /// distinguishing from a capture of nothing. + /// + /// Field 8: `raw_intent` + #[serde( + rename = "rawIntent", + alias = "raw_intent", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub raw_intent: ::buffa::MessageField>, + /// Free-text detail from the parser or validator, for humans. Never parsed. + /// + /// Field 9: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for ProviderToolIntentRejected { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProviderToolIntentRejected") + .field("session_id", &self.session_id) + .field("rejection_id", &self.rejection_id) + .field("message_id", &self.message_id) + .field("turn_id", &self.turn_id) + .field("reason", &self.reason) + .field("claimed_tool_call_id", &self.claimed_tool_call_id) + .field("claimed_tool_name", &self.claimed_tool_name) + .field("raw_intent", &self.raw_intent) + .field("detail", &self.detail) + .finish() + } +} +impl ProviderToolIntentRejected { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected"; +} +impl ProviderToolIntentRejected { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::claimed_tool_call_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_claimed_tool_call_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.claimed_tool_call_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::claimed_tool_name`] to `Some(value)`, consuming and returning `self`. + pub fn with_claimed_tool_name( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.claimed_tool_name = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ProviderToolIntentRejected); +impl ::buffa::MessageName for ProviderToolIntentRejected { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ProviderToolIntentRejected"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected"; +} +impl ::buffa::Message for ProviderToolIntentRejected { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.rejection_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.claimed_tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.claimed_tool_name { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.raw_intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.rejection_id, buf); + ::buffa::types::put_string_field(3u32, &self.message_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.claimed_tool_call_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.claimed_tool_name { + ::buffa::types::put_string_field(7u32, v, buf); + } + if self.raw_intent.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.raw_intent.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(9u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.rejection_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .claimed_tool_call_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .claimed_tool_name + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.raw_intent.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.rejection_id.clear(); + self.message_id.clear(); + self.turn_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.claimed_tool_call_id = ::core::option::Option::None; + self.claimed_tool_name = ::core::option::Option::None; + self.raw_intent = ::buffa::MessageField::none(); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProviderToolIntentRejected { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PROVIDER_TOOL_INTENT_REJECTED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ProviderToolIntentRejected", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.__view.rs new file mode 100644 index 0000000000..03eb49c421 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.__view.rs @@ -0,0 +1,410 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reconcile_parent_rewind.proto + +/// ReconcileParentRewind is issued by the child-session reconciler when a parent +/// rewinds past the dispatch that created a child, recording +/// \[ParentHistoryInvalidated, SessionCancelled\] as one batch: the context the +/// child inherited no longer exists. +/// +/// Write precondition At on the child: applies only when parent_dispatched_at is +/// past the parent's new boundary and the cascade policy allows it. +#[derive(Clone, Debug, Default)] +pub struct ReconcileParentRewindView<'a> { + /// The child session being reconciled. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `parent_session_id` + pub parent_session_id: &'a str, + /// The parent's new effective boundary. + /// + /// Field 3: `parent_keep_through` + pub parent_keep_through: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 4: `triggering_event_id` + pub triggering_event_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileParentRewindView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `parent_keep_through` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_keep_through(&self) -> bool { + self.parent_keep_through.is_set() + } + /**Whether required field `triggering_event_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_triggering_event_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileParentRewindView<'a> { + type Owned = super::super::ReconcileParentRewind; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.parent_keep_through.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.parent_keep_through = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.triggering_event_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileParentRewind, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileParentRewind, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileParentRewind { + session_id: self.session_id.to_string(), + parent_session_id: self.parent_session_id.to_string(), + parent_keep_through: match self.parent_keep_through.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + triggering_event_id: self.triggering_event_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileParentRewindView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.triggering_event_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + if self.parent_keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_keep_through.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.triggering_event_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileParentRewindView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .parent_keep_through + .as_option() + { + __map.serialize_entry("parentKeepThrough", __v)?; + } + } + { + __map.serialize_entry("triggeringEventId", self.triggering_event_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileParentRewindView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReconcileParentRewind"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReconcileParentRewind"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentRewind"; +} +::buffa::impl_default_view_instance!(ReconcileParentRewindView); +::buffa::impl_view_reborrow!(ReconcileParentRewindView); +/** Self-contained, `'static` owned view of a `ReconcileParentRewind` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileParentRewindView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileParentRewindView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileParentRewindOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileParentRewindOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentRewindOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentRewindOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileParentRewind, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentRewindOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileParentRewindView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileParentRewindView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileParentRewind { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The child session being reconciled. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// The parent's new effective boundary. + /// + /// Field 3: `parent_keep_through` + #[must_use] + pub fn parent_keep_through( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().parent_keep_through + } + /// Field 4: `triggering_event_id` + #[must_use] + pub fn triggering_event_id(&self) -> &'_ str { + self.0.reborrow().triggering_event_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileParentRewindOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReconcileParentRewindOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileParentRewindOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileParentRewindOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileParentRewind { + type View<'a> = ReconcileParentRewindView<'a>; + type ViewHandle = ReconcileParentRewindOwnedView; +} +impl ::serde::Serialize for ReconcileParentRewindOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.rs new file mode 100644 index 0000000000..8f3de08e94 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_rewind.rs @@ -0,0 +1,194 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reconcile_parent_rewind.proto + +/// ReconcileParentRewind is issued by the child-session reconciler when a parent +/// rewinds past the dispatch that created a child, recording +/// \[ParentHistoryInvalidated, SessionCancelled\] as one batch: the context the +/// child inherited no longer exists. +/// +/// Write precondition At on the child: applies only when parent_dispatched_at is +/// past the parent's new boundary and the cascade policy allows it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileParentRewind { + /// The child session being reconciled. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// The parent's new effective boundary. + /// + /// Field 3: `parent_keep_through` + #[serde(rename = "parentKeepThrough", alias = "parent_keep_through")] + pub parent_keep_through: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 4: `triggering_event_id` + #[serde( + rename = "triggeringEventId", + alias = "triggering_event_id", + with = "::buffa::json_helpers::proto_string" + )] + pub triggering_event_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for ReconcileParentRewind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileParentRewind") + .field("session_id", &self.session_id) + .field("parent_session_id", &self.parent_session_id) + .field("parent_keep_through", &self.parent_keep_through) + .field("triggering_event_id", &self.triggering_event_id) + .finish() + } +} +impl ReconcileParentRewind { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentRewind"; +} +::buffa::impl_default_instance!(ReconcileParentRewind); +impl ::buffa::MessageName for ReconcileParentRewind { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReconcileParentRewind"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReconcileParentRewind"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentRewind"; +} +impl ::buffa::Message for ReconcileParentRewind { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + if self.parent_keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.parent_keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.triggering_event_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + if self.parent_keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.parent_keep_through.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.triggering_event_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.parent_keep_through.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.triggering_event_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.parent_session_id.clear(); + self.parent_keep_through = ::buffa::MessageField::none(); + self.triggering_event_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileParentRewind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_PARENT_REWIND_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentRewind", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.__view.rs new file mode 100644 index 0000000000..84adc350b8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.__view.rs @@ -0,0 +1,371 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reconcile_parent_terminal.proto + +/// ReconcileParentTerminal is issued by the child-session reconciler when a +/// parent reaches a terminal state, recording \[ParentTerminated, +/// SessionCancelled\] against the child as one batch. Recording the observation +/// and the consequence together is what closes the silent-orphan gap. +/// +/// Write precondition At on the child: a no-op if the child is already terminal. +/// The cancellation reason is derived by the aggregate, not carried here. +#[derive(Clone, Debug, Default)] +pub struct ReconcileParentTerminalView<'a> { + /// The child session being reconciled. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `parent_session_id` + pub parent_session_id: &'a str, + /// Field 3: `cause` + pub cause: ::buffa::EnumValue, + /// The parent event that triggered this reconcile, so a redelivery is + /// recognisable as the same observation. + /// + /// Field 4: `triggering_event_id` + pub triggering_event_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileParentTerminalView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `parent_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_parent_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `cause` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_cause(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `triggering_event_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_triggering_event_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileParentTerminalView<'a> { + type Owned = super::super::ReconcileParentTerminal; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.cause = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.triggering_event_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileParentTerminal, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileParentTerminal, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileParentTerminal { + session_id: self.session_id.to_string(), + parent_session_id: self.parent_session_id.to_string(), + cause: self.cause, + triggering_event_id: self.triggering_event_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileParentTerminalView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + { + let val = self.cause.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.triggering_event_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + ::buffa::types::put_int32_field(3u32, self.cause.to_i32(), buf); + ::buffa::types::put_string_field(4u32, &self.triggering_event_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileParentTerminalView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("parentSessionId", self.parent_session_id)?; + } + { + __map.serialize_entry("cause", &self.cause)?; + } + { + __map.serialize_entry("triggeringEventId", self.triggering_event_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileParentTerminalView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReconcileParentTerminal"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReconcileParentTerminal"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentTerminal"; +} +::buffa::impl_default_view_instance!(ReconcileParentTerminalView); +::buffa::impl_view_reborrow!(ReconcileParentTerminalView); +/** Self-contained, `'static` owned view of a `ReconcileParentTerminal` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileParentTerminalView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileParentTerminalView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileParentTerminalOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileParentTerminalOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentTerminalOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentTerminalOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileParentTerminal, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileParentTerminalOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileParentTerminalView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileParentTerminalView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileParentTerminal { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The child session being reconciled. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `parent_session_id` + #[must_use] + pub fn parent_session_id(&self) -> &'_ str { + self.0.reborrow().parent_session_id + } + /// Field 3: `cause` + #[must_use] + pub fn cause(&self) -> ::buffa::EnumValue { + self.0.reborrow().cause + } + /// The parent event that triggered this reconcile, so a redelivery is + /// recognisable as the same observation. + /// + /// Field 4: `triggering_event_id` + #[must_use] + pub fn triggering_event_id(&self) -> &'_ str { + self.0.reborrow().triggering_event_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileParentTerminalOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReconcileParentTerminalOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileParentTerminalOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileParentTerminalOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileParentTerminal { + type View<'a> = ReconcileParentTerminalView<'a>; + type ViewHandle = ReconcileParentTerminalOwnedView; +} +impl ::serde::Serialize for ReconcileParentTerminalOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.rs new file mode 100644 index 0000000000..ce7fe4b202 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reconcile_parent_terminal.rs @@ -0,0 +1,179 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reconcile_parent_terminal.proto + +/// ReconcileParentTerminal is issued by the child-session reconciler when a +/// parent reaches a terminal state, recording \[ParentTerminated, +/// SessionCancelled\] against the child as one batch. Recording the observation +/// and the consequence together is what closes the silent-orphan gap. +/// +/// Write precondition At on the child: a no-op if the child is already terminal. +/// The cancellation reason is derived by the aggregate, not carried here. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileParentTerminal { + /// The child session being reconciled. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `parent_session_id` + #[serde( + rename = "parentSessionId", + alias = "parent_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub parent_session_id: ::buffa::alloc::string::String, + /// Field 3: `cause` + #[serde(rename = "cause", with = "::buffa::json_helpers::proto_enum")] + pub cause: ::buffa::EnumValue, + /// The parent event that triggered this reconcile, so a redelivery is + /// recognisable as the same observation. + /// + /// Field 4: `triggering_event_id` + #[serde( + rename = "triggeringEventId", + alias = "triggering_event_id", + with = "::buffa::json_helpers::proto_string" + )] + pub triggering_event_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for ReconcileParentTerminal { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileParentTerminal") + .field("session_id", &self.session_id) + .field("parent_session_id", &self.parent_session_id) + .field("cause", &self.cause) + .field("triggering_event_id", &self.triggering_event_id) + .finish() + } +} +impl ReconcileParentTerminal { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentTerminal"; +} +::buffa::impl_default_instance!(ReconcileParentTerminal); +impl ::buffa::MessageName for ReconcileParentTerminal { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReconcileParentTerminal"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReconcileParentTerminal"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentTerminal"; +} +impl ::buffa::Message for ReconcileParentTerminal { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.parent_session_id) as u64; + { + let val = self.cause.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.triggering_event_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.parent_session_id, buf); + ::buffa::types::put_int32_field(3u32, self.cause.to_i32(), buf); + ::buffa::types::put_string_field(4u32, &self.triggering_event_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.parent_session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.cause = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.triggering_event_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.parent_session_id.clear(); + self.cause = ::buffa::EnumValue::from(0); + self.triggering_event_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileParentTerminal { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_PARENT_TERMINAL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReconcileParentTerminal", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.__view.rs new file mode 100644 index 0000000000..f63e1d87ec --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.__view.rs @@ -0,0 +1,327 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_artifact.proto + +/// RecordArtifact registers an artifact by claim-check, recording +/// \[ArtifactRecorded\]. Bytes are never inlined on the log (ADR#0035 facet 3). +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct RecordArtifactView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `artifact` + pub artifact: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactMetadataView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecordArtifactView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `artifact` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_artifact(&self) -> bool { + self.artifact.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for RecordArtifactView<'a> { + type Owned = super::super::RecordArtifact; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.artifact.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.artifact = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecordArtifact { + session_id: self.session_id.to_string(), + artifact: match self.artifact.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactMetadata, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecordArtifactView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.artifact.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifact.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.artifact.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifact.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecordArtifactView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.artifact.as_option() { + __map.serialize_entry("artifact", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecordArtifactView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordArtifact"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordArtifact"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordArtifact"; +} +::buffa::impl_default_view_instance!(RecordArtifactView); +::buffa::impl_view_reborrow!(RecordArtifactView); +/** Self-contained, `'static` owned view of a `RecordArtifact` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecordArtifactView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecordArtifactView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecordArtifactOwnedView(::buffa::OwnedView>); +impl RecordArtifactOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordArtifactOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordArtifactOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecordArtifact, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordArtifactOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecordArtifactView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecordArtifactView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecordArtifact { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `artifact` + #[must_use] + pub fn artifact( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactMetadataView<'_>, + > { + &self.0.reborrow().artifact + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecordArtifactOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecordArtifactOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecordArtifactOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecordArtifactOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecordArtifact { + type View<'a> = RecordArtifactView<'a>; + type ViewHandle = RecordArtifactOwnedView; +} +impl ::serde::Serialize for RecordArtifactOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.rs new file mode 100644 index 0000000000..7432ac0d6b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_artifact.rs @@ -0,0 +1,148 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_artifact.proto + +/// RecordArtifact registers an artifact by claim-check, recording +/// \[ArtifactRecorded\]. Bytes are never inlined on the log (ADR#0035 facet 3). +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecordArtifact { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `artifact` + #[serde(rename = "artifact")] + pub artifact: ::buffa::MessageField< + ArtifactMetadata, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for RecordArtifact { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecordArtifact") + .field("session_id", &self.session_id) + .field("artifact", &self.artifact) + .finish() + } +} +impl RecordArtifact { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordArtifact"; +} +::buffa::impl_default_instance!(RecordArtifact); +impl ::buffa::MessageName for RecordArtifact { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordArtifact"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordArtifact"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordArtifact"; +} +impl ::buffa::Message for RecordArtifact { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.artifact.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.artifact.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.artifact.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.artifact.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.artifact.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.artifact = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecordArtifact { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECORD_ARTIFACT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordArtifact", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.__view.rs new file mode 100644 index 0000000000..35b5fab2ff --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.__view.rs @@ -0,0 +1,608 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_file_change.proto + +/// RecordFileChange attributes a workspace file change to the tool call that +/// caused it, recording \[FileChanged\]. A change with no proximate call is not +/// this command: it surfaces as a ResourceObservation whose digest moved, +/// meaning something outside the session touched the file. +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct RecordFileChangeView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 2: `path` + pub path: &'a str, + /// Field 3: `change_kind` + pub change_kind: ::buffa::EnumValue, + /// Field 4: `previous_path` + pub previous_path: ::core::option::Option<&'a str>, + /// Content before the change; unset for a create or when not captured. + /// Recorded because checkpoints are opaque, so what changed is not + /// re-derivable by diffing them afterwards. + /// + /// Field 5: `before_ref` + pub before_ref: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + /// Field 6: `after_ref` + pub after_ref: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + /// The causing call. Without it, which call touched this file is only + /// answerable by fold adjacency, which concurrent Any appends make + /// unsound. + /// + /// Field 7: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 8: `turn_id` + pub turn_id: &'a str, + /// Field 9: `diff` + pub diff: ::buffa::MessageFieldView< + super::super::__buffa::view::DiffSummaryView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecordFileChangeView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `path` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_path(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `change_kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_change_kind(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecordFileChangeView<'a> { + type Owned = super::super::RecordFileChange; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.path = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.change_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.previous_path = Some(::buffa::types::borrow_str(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.before_ref.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.before_ref = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.after_ref.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.after_ref = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.diff.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.diff = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecordFileChange { + session_id: self.session_id.to_string(), + path: self.path.to_string(), + change_kind: self.change_kind, + previous_path: self.previous_path.map(|s| s.to_string()), + before_ref: match self.before_ref.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + after_ref: match self.after_ref.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + tool_call_id: self.tool_call_id.to_string(), + turn_id: self.turn_id.to_string(), + diff: match self.diff.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::DiffSummary, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecordFileChangeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + { + let val = self.change_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.previous_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.before_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.before_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.after_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.after_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.diff.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.diff.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.path, buf); + ::buffa::types::put_int32_field(3u32, self.change_kind.to_i32(), buf); + if let Some(ref v) = self.previous_path { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.before_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.before_ref.write_to(__cache, buf); + } + if self.after_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.after_ref.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(8u32, &self.turn_id, buf); + if self.diff.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.diff.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecordFileChangeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("path", self.path)?; + } + { + __map.serialize_entry("changeKind", &self.change_kind)?; + } + if let ::core::option::Option::Some(__v) = self.previous_path { + __map.serialize_entry("previousPath", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.before_ref.as_option() { + __map.serialize_entry("beforeRef", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.after_ref.as_option() { + __map.serialize_entry("afterRef", __v)?; + } + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.diff.as_option() { + __map.serialize_entry("diff", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecordFileChangeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordFileChange"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordFileChange"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordFileChange"; +} +::buffa::impl_default_view_instance!(RecordFileChangeView); +::buffa::impl_view_reborrow!(RecordFileChangeView); +/** Self-contained, `'static` owned view of a `RecordFileChange` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecordFileChangeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecordFileChangeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecordFileChangeOwnedView(::buffa::OwnedView>); +impl RecordFileChangeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordFileChangeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordFileChangeOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecordFileChange, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordFileChangeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecordFileChangeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecordFileChangeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecordFileChange { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 2: `path` + #[must_use] + pub fn path(&self) -> &'_ str { + self.0.reborrow().path + } + /// Field 3: `change_kind` + #[must_use] + pub fn change_kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().change_kind + } + /// Field 4: `previous_path` + #[must_use] + pub fn previous_path(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().previous_path + } + /// Content before the change; unset for a create or when not captured. + /// Recorded because checkpoints are opaque, so what changed is not + /// re-derivable by diffing them afterwards. + /// + /// Field 5: `before_ref` + #[must_use] + pub fn before_ref( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().before_ref + } + /// Field 6: `after_ref` + #[must_use] + pub fn after_ref( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().after_ref + } + /// The causing call. Without it, which call touched this file is only + /// answerable by fold adjacency, which concurrent Any appends make + /// unsound. + /// + /// Field 7: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 8: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 9: `diff` + #[must_use] + pub fn diff( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().diff + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecordFileChangeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecordFileChangeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecordFileChangeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecordFileChangeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecordFileChange { + type View<'a> = RecordFileChangeView<'a>; + type ViewHandle = RecordFileChangeOwnedView; +} +impl ::serde::Serialize for RecordFileChangeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.rs new file mode 100644 index 0000000000..aa3311adc7 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_file_change.rs @@ -0,0 +1,344 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_file_change.proto + +/// RecordFileChange attributes a workspace file change to the tool call that +/// caused it, recording \[FileChanged\]. A change with no proximate call is not +/// this command: it surfaces as a ResourceObservation whose digest moved, +/// meaning something outside the session touched the file. +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecordFileChange { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Workspace-relative, forward slashes, no leading slash. + /// + /// Field 2: `path` + #[serde(rename = "path", with = "::buffa::json_helpers::proto_string")] + pub path: ::buffa::alloc::string::String, + /// Field 3: `change_kind` + #[serde( + rename = "changeKind", + alias = "change_kind", + with = "::buffa::json_helpers::proto_enum" + )] + pub change_kind: ::buffa::EnumValue, + /// Field 4: `previous_path` + #[serde( + rename = "previousPath", + alias = "previous_path", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub previous_path: ::core::option::Option<::buffa::alloc::string::String>, + /// Content before the change; unset for a create or when not captured. + /// Recorded because checkpoints are opaque, so what changed is not + /// re-derivable by diffing them afterwards. + /// + /// Field 5: `before_ref` + #[serde( + rename = "beforeRef", + alias = "before_ref", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub before_ref: ::buffa::MessageField>, + /// Field 6: `after_ref` + #[serde( + rename = "afterRef", + alias = "after_ref", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub after_ref: ::buffa::MessageField>, + /// The causing call. Without it, which call touched this file is only + /// answerable by fold adjacency, which concurrent Any appends make + /// unsound. + /// + /// Field 7: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 8: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 9: `diff` + #[serde( + rename = "diff", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub diff: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for RecordFileChange { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecordFileChange") + .field("session_id", &self.session_id) + .field("path", &self.path) + .field("change_kind", &self.change_kind) + .field("previous_path", &self.previous_path) + .field("before_ref", &self.before_ref) + .field("after_ref", &self.after_ref) + .field("tool_call_id", &self.tool_call_id) + .field("turn_id", &self.turn_id) + .field("diff", &self.diff) + .finish() + } +} +impl RecordFileChange { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordFileChange"; +} +impl RecordFileChange { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::previous_path`] to `Some(value)`, consuming and returning `self`. + pub fn with_previous_path( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.previous_path = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RecordFileChange); +impl ::buffa::MessageName for RecordFileChange { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordFileChange"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordFileChange"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordFileChange"; +} +impl ::buffa::Message for RecordFileChange { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.path) as u64; + { + let val = self.change_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.previous_path { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.before_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.before_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.after_ref.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.after_ref.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.diff.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.diff.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.path, buf); + ::buffa::types::put_int32_field(3u32, self.change_kind.to_i32(), buf); + if let Some(ref v) = self.previous_path { + ::buffa::types::put_string_field(4u32, v, buf); + } + if self.before_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.before_ref.write_to(__cache, buf); + } + if self.after_ref.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.after_ref.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(8u32, &self.turn_id, buf); + if self.diff.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.diff.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.path, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.change_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .previous_path + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.before_ref.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.after_ref.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.diff.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.path.clear(); + self.change_kind = ::buffa::EnumValue::from(0); + self.previous_path = ::core::option::Option::None; + self.before_ref = ::buffa::MessageField::none(); + self.after_ref = ::buffa::MessageField::none(); + self.tool_call_id.clear(); + self.turn_id.clear(); + self.diff = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecordFileChange { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECORD_FILE_CHANGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordFileChange", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__oneof.rs new file mode 100644 index 0000000000..51e3594a63 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__oneof.rs @@ -0,0 +1,82 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_operation_outcome.proto + +pub mod record_operation_outcome { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Outcome { + Succeeded(::buffa::alloc::boxed::Box), + Failed(::buffa::alloc::boxed::Box), + Cancelled(::buffa::alloc::boxed::Box), + Unknown(::buffa::alloc::boxed::Box), + } + impl ::buffa::Oneof for Outcome {} + impl From for Outcome { + fn from(v: super::super::super::OperationSucceeded) -> Self { + Self::Succeeded(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::OperationSucceeded) -> Self { + Self::Some(Outcome::from(v)) + } + } + impl From for Outcome { + fn from(v: super::super::super::OperationFailed) -> Self { + Self::Failed(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From for ::core::option::Option { + fn from(v: super::super::super::OperationFailed) -> Self { + Self::Some(Outcome::from(v)) + } + } + impl From for Outcome { + fn from(v: super::super::super::OperationCancelled) -> Self { + Self::Cancelled(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::OperationCancelled) -> Self { + Self::Some(Outcome::from(v)) + } + } + impl From for Outcome { + fn from(v: super::super::super::OperationUnknown) -> Self { + Self::Unknown(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::OperationUnknown) -> Self { + Self::Some(Outcome::from(v)) + } + } + impl serde::Serialize for Outcome { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::Succeeded(v) => { + map.serialize_entry("succeeded", v)?; + } + Self::Failed(v) => { + map.serialize_entry("failed", v)?; + } + Self::Cancelled(v) => { + map.serialize_entry("cancelled", v)?; + } + Self::Unknown(v) => { + map.serialize_entry("unknown", v)?; + } + } + map.end() + } + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view.rs new file mode 100644 index 0000000000..7176593055 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view.rs @@ -0,0 +1,589 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_operation_outcome.proto + +/// RecordOperationOutcome settles a reserved operation, recording +/// \[OperationOutcomeRecorded\]. It is how an interrupted side effect stops being +/// in flight, and it stays admissible after the session is terminal so work +/// stranded by a cancellation can still be reconciled. +/// +/// Write precondition At: one determinate outcome per operation_id. An `unknown` +/// outcome is not determinate; it may be superseded exactly once by a +/// determinate one. +#[derive(Clone, Debug, Default)] +pub struct RecordOperationOutcomeView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `operation_id` + pub operation_id: &'a str, + pub outcome: ::core::option::Option< + super::super::__buffa::view::oneof::record_operation_outcome::Outcome<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecordOperationOutcomeView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecordOperationOutcomeView<'a> { + type Owned = super::super::RecordOperationOutcome; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + ref mut existing, + ), + ) = view.outcome + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.outcome = Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + ref mut existing, + ), + ) = view.outcome + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.outcome = Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + ref mut existing, + ), + ) = view.outcome + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.outcome = Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + ref mut existing, + ), + ) = view.outcome + { + ::buffa::MessageView::merge_into_view( + &mut **existing, + sub, + __sub_ctx, + )?; + } else { + view.outcome = Some( + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + ::buffa::alloc::boxed::Box::new( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RecordOperationOutcome, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RecordOperationOutcome, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecordOperationOutcome { + session_id: self.session_id.to_string(), + operation_id: self.operation_id.to_string(), + outcome: match self.outcome.as_ref() { + ::core::option::Option::Some(v) => { + ::core::option::Option::Some( + match v { + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + v, + ) => { + super::super::__buffa::oneof::record_operation_outcome::Outcome::Succeeded( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + v, + ) => { + super::super::__buffa::oneof::record_operation_outcome::Outcome::Failed( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + v, + ) => { + super::super::__buffa::oneof::record_operation_outcome::Outcome::Cancelled( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + v, + ) => { + super::super::__buffa::oneof::record_operation_outcome::Outcome::Unknown( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src)?, + ), + ) + } + }, + ) + } + ::core::option::Option::None => ::core::option::Option::None, + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecordOperationOutcomeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if let ::core::option::Option::Some(ref v) = self.outcome { + match v { + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if let ::core::option::Option::Some(ref v) = self.outcome { + match v { + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + x, + ) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecordOperationOutcomeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + if let ::core::option::Option::Some(ref __ov) = self.outcome { + match __ov { + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Succeeded( + v, + ) => { + __map.serialize_entry("succeeded", v)?; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Failed( + v, + ) => { + __map.serialize_entry("failed", v)?; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Cancelled( + v, + ) => { + __map.serialize_entry("cancelled", v)?; + } + super::super::__buffa::view::oneof::record_operation_outcome::Outcome::Unknown( + v, + ) => { + __map.serialize_entry("unknown", v)?; + } + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecordOperationOutcomeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordOperationOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordOperationOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordOperationOutcome"; +} +::buffa::impl_default_view_instance!(RecordOperationOutcomeView); +::buffa::impl_view_reborrow!(RecordOperationOutcomeView); +/** Self-contained, `'static` owned view of a `RecordOperationOutcome` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecordOperationOutcomeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecordOperationOutcomeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecordOperationOutcomeOwnedView( + ::buffa::OwnedView>, +); +impl RecordOperationOutcomeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordOperationOutcomeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordOperationOutcomeOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecordOperationOutcome, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordOperationOutcomeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecordOperationOutcomeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecordOperationOutcomeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecordOperationOutcome { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Oneof `outcome`. + #[must_use] + pub fn outcome( + &self, + ) -> ::core::option::Option< + &super::super::__buffa::view::oneof::record_operation_outcome::Outcome<'_>, + > { + self.0.reborrow().outcome.as_ref() + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecordOperationOutcomeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecordOperationOutcomeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecordOperationOutcomeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecordOperationOutcomeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecordOperationOutcome { + type View<'a> = RecordOperationOutcomeView<'a>; + type ViewHandle = RecordOperationOutcomeOwnedView; +} +impl ::serde::Serialize for RecordOperationOutcomeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view_oneof.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view_oneof.rs new file mode 100644 index 0000000000..cda8257b4b --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.__view_oneof.rs @@ -0,0 +1,30 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_operation_outcome.proto + +pub mod record_operation_outcome { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Outcome<'a> { + Succeeded( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OperationSucceededView<'a>, + >, + ), + Failed( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OperationFailedView<'a>, + >, + ), + Cancelled( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OperationCancelledView<'a>, + >, + ), + Unknown( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::OperationUnknownView<'a>, + >, + ), + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.rs new file mode 100644 index 0000000000..c99ab622c8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_operation_outcome.rs @@ -0,0 +1,486 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_operation_outcome.proto + +/// RecordOperationOutcome settles a reserved operation, recording +/// \[OperationOutcomeRecorded\]. It is how an interrupted side effect stops being +/// in flight, and it stays admissible after the session is terminal so work +/// stranded by a cancellation can still be reconciled. +/// +/// Write precondition At: one determinate outcome per operation_id. An `unknown` +/// outcome is not determinate; it may be superseded exactly once by a +/// determinate one. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct RecordOperationOutcome { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + #[serde(flatten)] + pub outcome: ::core::option::Option< + __buffa::oneof::record_operation_outcome::Outcome, + >, +} +impl ::core::fmt::Debug for RecordOperationOutcome { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecordOperationOutcome") + .field("session_id", &self.session_id) + .field("operation_id", &self.operation_id) + .field("outcome", &self.outcome) + .finish() + } +} +impl RecordOperationOutcome { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordOperationOutcome"; +} +::buffa::impl_default_instance!(RecordOperationOutcome); +impl ::buffa::MessageName for RecordOperationOutcome { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordOperationOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordOperationOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordOperationOutcome"; +} +impl ::buffa::Message for RecordOperationOutcome { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if let ::core::option::Option::Some(ref v) = self.outcome { + match v { + __buffa::oneof::record_operation_outcome::Outcome::Succeeded(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::record_operation_outcome::Outcome::Failed(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::record_operation_outcome::Outcome::Cancelled(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + __buffa::oneof::record_operation_outcome::Outcome::Unknown(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64 + + inner as u64; + } + } + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if let ::core::option::Option::Some(ref v) = self.outcome { + match v { + __buffa::oneof::record_operation_outcome::Outcome::Succeeded(x) => { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::record_operation_outcome::Outcome::Failed(x) => { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::record_operation_outcome::Outcome::Cancelled(x) => { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + __buffa::oneof::record_operation_outcome::Outcome::Unknown(x) => { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Succeeded( + ref mut existing, + ), + ) = self.outcome + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.outcome = ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Succeeded( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Failed( + ref mut existing, + ), + ) = self.outcome + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.outcome = ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Failed( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Cancelled( + ref mut existing, + ), + ) = self.outcome + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.outcome = ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Cancelled( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + if let ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Unknown( + ref mut existing, + ), + ) = self.outcome + { + ::buffa::Message::merge_length_delimited(&mut **existing, buf, ctx)?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, ctx)?; + self.outcome = ::core::option::Option::Some( + __buffa::oneof::record_operation_outcome::Outcome::Unknown( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.operation_id.clear(); + self.outcome = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for RecordOperationOutcome { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = RecordOperationOutcome; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct RecordOperationOutcome") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __f_session_id: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __f_operation_id: ::core::option::Option< + ::buffa::alloc::string::String, + > = None; + let mut __oneof_outcome: ::core::option::Option< + __buffa::oneof::record_operation_outcome::Outcome, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "sessionId" | "session_id" => { + __f_session_id = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "operationId" | "operation_id" => { + __f_operation_id = Some({ + struct _S; + impl<'de> serde::de::DeserializeSeed<'de> for _S { + type Value = ::buffa::alloc::string::String; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result< + ::buffa::alloc::string::String, + D::Error, + > { + ::buffa::json_helpers::proto_string::deserialize(d) + } + } + map.next_value_seed(_S)? + }); + } + "succeeded" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OperationSucceeded, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_outcome.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'outcome'", + ), + ); + } + __oneof_outcome = Some( + __buffa::oneof::record_operation_outcome::Outcome::Succeeded( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "failed" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OperationFailed, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_outcome.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'outcome'", + ), + ); + } + __oneof_outcome = Some( + __buffa::oneof::record_operation_outcome::Outcome::Failed( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "cancelled" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OperationCancelled, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_outcome.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'outcome'", + ), + ); + } + __oneof_outcome = Some( + __buffa::oneof::record_operation_outcome::Outcome::Cancelled( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "unknown" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + OperationUnknown, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_outcome.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'outcome'", + ), + ); + } + __oneof_outcome = Some( + __buffa::oneof::record_operation_outcome::Outcome::Unknown( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + if let ::core::option::Option::Some(v) = __f_session_id { + __r.session_id = v; + } + if let ::core::option::Option::Some(v) = __f_operation_id { + __r.operation_id = v; + } + __r.outcome = __oneof_outcome; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecordOperationOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECORD_OPERATION_OUTCOME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordOperationOutcome", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod record_operation_outcome { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::__buffa::oneof::record_operation_outcome::Outcome; + #[doc(inline)] + pub use super::__buffa::view::oneof::record_operation_outcome::Outcome as OutcomeView; +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.__view.rs new file mode 100644 index 0000000000..f036ce219d --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.__view.rs @@ -0,0 +1,349 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_system_notice.proto + +/// RecordSystemNotice appends a system-originated notice, recording +/// \[SystemNoticeRecorded\], so model-visible system content and the user-visible +/// transcript both rebuild from the log alone (ADR#0035 facet 8). +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct RecordSystemNoticeView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `level` + pub level: ::buffa::EnumValue, + /// Field 3: `text` + pub text: &'a str, + /// Set when the notice concerns a specific call. + /// + /// Field 4: `tool_call_id` + pub tool_call_id: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecordSystemNoticeView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `level` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_level(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `text` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_text(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecordSystemNoticeView<'a> { + type Owned = super::super::RecordSystemNotice; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.level = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.text = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecordSystemNotice { + session_id: self.session_id.to_string(), + level: self.level, + text: self.text.to_string(), + tool_call_id: self.tool_call_id.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecordSystemNoticeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.level.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + if let Some(ref v) = self.tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.level.to_i32(), buf); + ::buffa::types::put_string_field(3u32, &self.text, buf); + if let Some(ref v) = self.tool_call_id { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecordSystemNoticeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("level", &self.level)?; + } + { + __map.serialize_entry("text", self.text)?; + } + if let ::core::option::Option::Some(__v) = self.tool_call_id { + __map.serialize_entry("toolCallId", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecordSystemNoticeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordSystemNotice"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordSystemNotice"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordSystemNotice"; +} +::buffa::impl_default_view_instance!(RecordSystemNoticeView); +::buffa::impl_view_reborrow!(RecordSystemNoticeView); +/** Self-contained, `'static` owned view of a `RecordSystemNotice` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecordSystemNoticeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecordSystemNoticeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecordSystemNoticeOwnedView( + ::buffa::OwnedView>, +); +impl RecordSystemNoticeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordSystemNoticeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordSystemNoticeOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecordSystemNotice, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordSystemNoticeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecordSystemNoticeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecordSystemNoticeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecordSystemNotice { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `level` + #[must_use] + pub fn level(&self) -> ::buffa::EnumValue { + self.0.reborrow().level + } + /// Field 3: `text` + #[must_use] + pub fn text(&self) -> &'_ str { + self.0.reborrow().text + } + /// Set when the notice concerns a specific call. + /// + /// Field 4: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().tool_call_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecordSystemNoticeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecordSystemNoticeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecordSystemNoticeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecordSystemNoticeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecordSystemNotice { + type View<'a> = RecordSystemNoticeView<'a>; + type ViewHandle = RecordSystemNoticeOwnedView; +} +impl ::serde::Serialize for RecordSystemNoticeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.rs new file mode 100644 index 0000000000..133322153f --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_system_notice.rs @@ -0,0 +1,188 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_system_notice.proto + +/// RecordSystemNotice appends a system-originated notice, recording +/// \[SystemNoticeRecorded\], so model-visible system content and the user-visible +/// transcript both rebuild from the log alone (ADR#0035 facet 8). +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecordSystemNotice { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `level` + #[serde(rename = "level", with = "::buffa::json_helpers::proto_enum")] + pub level: ::buffa::EnumValue, + /// Field 3: `text` + #[serde(rename = "text", with = "::buffa::json_helpers::proto_string")] + pub text: ::buffa::alloc::string::String, + /// Set when the notice concerns a specific call. + /// + /// Field 4: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub tool_call_id: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for RecordSystemNotice { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecordSystemNotice") + .field("session_id", &self.session_id) + .field("level", &self.level) + .field("text", &self.text) + .field("tool_call_id", &self.tool_call_id) + .finish() + } +} +impl RecordSystemNotice { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordSystemNotice"; +} +impl RecordSystemNotice { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::tool_call_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_tool_call_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.tool_call_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RecordSystemNotice); +impl ::buffa::MessageName for RecordSystemNotice { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordSystemNotice"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordSystemNotice"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordSystemNotice"; +} +impl ::buffa::Message for RecordSystemNotice { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + { + let val = self.level.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.text) as u64; + if let Some(ref v) = self.tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_int32_field(2u32, self.level.to_i32(), buf); + ::buffa::types::put_string_field(3u32, &self.text, buf); + if let Some(ref v) = self.tool_call_id { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.level = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.text, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .tool_call_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.level = ::buffa::EnumValue::from(0); + self.text.clear(); + self.tool_call_id = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecordSystemNotice { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECORD_SYSTEM_NOTICE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordSystemNotice", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.__view.rs new file mode 100644 index 0000000000..b460cd10a2 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.__view.rs @@ -0,0 +1,367 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_user_message.proto + +/// RecordUserMessage appends a user message, recording \[UserMessageRecorded\]. +/// +/// Write precondition Any: arrival of a message is a happened-fact that commutes +/// with other appends and carries no invariant a concurrent writer could break +/// (ADR#0035 facet 2). +#[derive(Clone, Debug, Default)] +pub struct RecordUserMessageView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `message` + pub message: ::buffa::MessageFieldView< + super::super::__buffa::view::CanonicalMessageView<'a>, + >, + /// The turn this message opens; every event produced within the turn + /// repeats it, because the fold cannot recover a boundary that concurrent + /// Any appends give no reliable ordering for. + /// + /// Field 3: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecordUserMessageView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message(&self) -> bool { + self.message.is_set() + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecordUserMessageView<'a> { + type Owned = super::super::RecordUserMessage; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.message.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.message = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecordUserMessage { + session_id: self.session_id.to_string(), + message: match self.message.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CanonicalMessage, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecordUserMessageView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.message.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.message.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecordUserMessageView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.message.as_option() { + __map.serialize_entry("message", __v)?; + } + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecordUserMessageView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordUserMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordUserMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordUserMessage"; +} +::buffa::impl_default_view_instance!(RecordUserMessageView); +::buffa::impl_view_reborrow!(RecordUserMessageView); +/** Self-contained, `'static` owned view of a `RecordUserMessage` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecordUserMessageView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecordUserMessageView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecordUserMessageOwnedView( + ::buffa::OwnedView>, +); +impl RecordUserMessageOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordUserMessageOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordUserMessageOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecordUserMessage, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecordUserMessageOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecordUserMessageView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecordUserMessageView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecordUserMessage { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `message` + #[must_use] + pub fn message( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CanonicalMessageView<'_>, + > { + &self.0.reborrow().message + } + /// The turn this message opens; every event produced within the turn + /// repeats it, because the fold cannot recover a boundary that concurrent + /// Any appends give no reliable ordering for. + /// + /// Field 3: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecordUserMessageOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecordUserMessageOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecordUserMessageOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecordUserMessageOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecordUserMessage { + type View<'a> = RecordUserMessageView<'a>; + type ViewHandle = RecordUserMessageOwnedView; +} +impl ::serde::Serialize for RecordUserMessageOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.rs new file mode 100644 index 0000000000..7dafcc0346 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.record_user_message.rs @@ -0,0 +1,171 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/record_user_message.proto + +/// RecordUserMessage appends a user message, recording \[UserMessageRecorded\]. +/// +/// Write precondition Any: arrival of a message is a happened-fact that commutes +/// with other appends and carries no invariant a concurrent writer could break +/// (ADR#0035 facet 2). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecordUserMessage { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `message` + #[serde(rename = "message")] + pub message: ::buffa::MessageField< + CanonicalMessage, + ::buffa::Inline, + >, + /// The turn this message opens; every event produced within the turn + /// repeats it, because the fold cannot recover a boundary that concurrent + /// Any appends give no reliable ordering for. + /// + /// Field 3: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for RecordUserMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecordUserMessage") + .field("session_id", &self.session_id) + .field("message", &self.message) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl RecordUserMessage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordUserMessage"; +} +::buffa::impl_default_instance!(RecordUserMessage); +impl ::buffa::MessageName for RecordUserMessage { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecordUserMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecordUserMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordUserMessage"; +} +impl ::buffa::Message for RecordUserMessage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.message.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.message.write_to(__cache, buf); + } + ::buffa::types::put_string_field(3u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.message.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.message = ::buffa::MessageField::none(); + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecordUserMessage { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECORD_USER_MESSAGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecordUserMessage", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.__view.rs new file mode 100644 index 0000000000..a9a72f762f --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.__view.rs @@ -0,0 +1,684 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/recover_session.proto + +/// RecoverSession opens a session carrying what a salvage could read from a +/// damaged source, recording \[SessionStarted, SessionRecovered\] as one batch. +/// +/// Write precondition NoStream on the new stream. The source is a different +/// aggregate and this decider never reads it, so what the salvage found is +/// carried on the command rather than derived here; the same rule ForkSession +/// follows. The NoStream precondition is what makes a retried salvage safe: a +/// second attempt derives the same session_id and is rejected instead of +/// producing a second copy. +/// +/// The salvaged events themselves are appended after this batch, as this +/// session's own events. This command records only that the session is a +/// recovery and how complete it is. +#[derive(Clone, Debug, Default)] +pub struct RecoverSessionView<'a> { + /// Derived from the salvage identity, never randomly minted. + /// + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_plan` + pub execution_plan: ::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'a>, + >, + /// Field 3: `workspace` + pub workspace: ::buffa::MessageFieldView< + super::super::__buffa::view::WorkspaceRefView<'a>, + >, + /// Field 4: `source_session_id` + pub source_session_id: &'a str, + /// The last source ordinal the salvage drew from. + /// + /// Field 5: `source_boundary` + pub source_boundary: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 6: `source_digest` + pub source_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 7: `salvage_key` + pub salvage_key: &'a str, + /// Field 8: `completeness` + pub completeness: ::buffa::EnumValue, + /// Field 9: `omitted_count` + pub omitted_count: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RecoverSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_plan` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_plan(&self) -> bool { + self.execution_plan.is_set() + } + /**Whether required field `workspace` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_workspace(&self) -> bool { + self.workspace.is_set() + } + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `source_boundary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_boundary(&self) -> bool { + self.source_boundary.is_set() + } + /**Whether required field `source_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_digest(&self) -> bool { + self.source_digest.is_set() + } + /**Whether required field `salvage_key` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_salvage_key(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `completeness` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `omitted_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_omitted_count(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RecoverSessionView<'a> { + type Owned = super::super::RecoverSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.execution_plan.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.execution_plan = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.workspace.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.workspace = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_boundary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_boundary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.salvage_key = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.omitted_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RecoverSession { + session_id: self.session_id.to_string(), + execution_plan: match self.execution_plan.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::StoredSessionExecutionPlan, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + workspace: match self.workspace.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::WorkspaceRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_session_id: self.source_session_id.to_string(), + source_boundary: match self.source_boundary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_digest: match self.source_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + salvage_key: self.salvage_key.to_string(), + completeness: self.completeness, + omitted_count: self.omitted_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RecoverSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(8u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(9u32, self.omitted_count, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RecoverSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.execution_plan.as_option() { + __map.serialize_entry("executionPlan", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.workspace.as_option() { + __map.serialize_entry("workspace", __v)?; + } + } + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.source_boundary.as_option() { + __map.serialize_entry("sourceBoundary", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.source_digest.as_option() { + __map.serialize_entry("sourceDigest", __v)?; + } + } + { + __map.serialize_entry("salvageKey", self.salvage_key)?; + } + { + __map.serialize_entry("completeness", &self.completeness)?; + } + { + __map + .serialize_entry( + "omittedCount", + &::buffa::json_helpers::ProtoJson(&self.omitted_count), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RecoverSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecoverSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecoverSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecoverSession"; +} +::buffa::impl_default_view_instance!(RecoverSessionView); +::buffa::impl_view_reborrow!(RecoverSessionView); +/** Self-contained, `'static` owned view of a `RecoverSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`RecoverSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RecoverSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RecoverSessionOwnedView(::buffa::OwnedView>); +impl RecoverSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoverSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoverSessionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RecoverSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RecoverSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RecoverSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RecoverSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RecoverSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Derived from the salvage identity, never randomly minted. + /// + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_plan` + #[must_use] + pub fn execution_plan( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::StoredSessionExecutionPlanView<'_>, + > { + &self.0.reborrow().execution_plan + } + /// Field 3: `workspace` + #[must_use] + pub fn workspace( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().workspace + } + /// Field 4: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// The last source ordinal the salvage drew from. + /// + /// Field 5: `source_boundary` + #[must_use] + pub fn source_boundary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().source_boundary + } + /// Field 6: `source_digest` + #[must_use] + pub fn source_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().source_digest + } + /// Field 7: `salvage_key` + #[must_use] + pub fn salvage_key(&self) -> &'_ str { + self.0.reborrow().salvage_key + } + /// Field 8: `completeness` + #[must_use] + pub fn completeness( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().completeness + } + /// Field 9: `omitted_count` + #[must_use] + pub fn omitted_count(&self) -> u32 { + self.0.reborrow().omitted_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RecoverSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RecoverSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RecoverSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RecoverSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RecoverSession { + type View<'a> = RecoverSessionView<'a>; + type ViewHandle = RecoverSessionOwnedView; +} +impl ::serde::Serialize for RecoverSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.rs new file mode 100644 index 0000000000..e49d271bd8 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.recover_session.rs @@ -0,0 +1,334 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/recover_session.proto + +/// RecoverSession opens a session carrying what a salvage could read from a +/// damaged source, recording \[SessionStarted, SessionRecovered\] as one batch. +/// +/// Write precondition NoStream on the new stream. The source is a different +/// aggregate and this decider never reads it, so what the salvage found is +/// carried on the command rather than derived here; the same rule ForkSession +/// follows. The NoStream precondition is what makes a retried salvage safe: a +/// second attempt derives the same session_id and is rejected instead of +/// producing a second copy. +/// +/// The salvaged events themselves are appended after this batch, as this +/// session's own events. This command records only that the session is a +/// recovery and how complete it is. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RecoverSession { + /// Derived from the salvage identity, never randomly minted. + /// + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_plan` + #[serde(rename = "executionPlan", alias = "execution_plan")] + pub execution_plan: ::buffa::MessageField< + StoredSessionExecutionPlan, + ::buffa::Inline, + >, + /// Field 3: `workspace` + #[serde(rename = "workspace")] + pub workspace: ::buffa::MessageField>, + /// Field 4: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// The last source ordinal the salvage drew from. + /// + /// Field 5: `source_boundary` + #[serde(rename = "sourceBoundary", alias = "source_boundary")] + pub source_boundary: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 6: `source_digest` + #[serde(rename = "sourceDigest", alias = "source_digest")] + pub source_digest: ::buffa::MessageField>, + /// Field 7: `salvage_key` + #[serde( + rename = "salvageKey", + alias = "salvage_key", + with = "::buffa::json_helpers::proto_string" + )] + pub salvage_key: ::buffa::alloc::string::String, + /// Field 8: `completeness` + #[serde(rename = "completeness", with = "::buffa::json_helpers::proto_enum")] + pub completeness: ::buffa::EnumValue, + /// Field 9: `omitted_count` + #[serde( + rename = "omittedCount", + alias = "omitted_count", + with = "::buffa::json_helpers::uint32" + )] + pub omitted_count: u32, +} +impl ::core::fmt::Debug for RecoverSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RecoverSession") + .field("session_id", &self.session_id) + .field("execution_plan", &self.execution_plan) + .field("workspace", &self.workspace) + .field("source_session_id", &self.source_session_id) + .field("source_boundary", &self.source_boundary) + .field("source_digest", &self.source_digest) + .field("salvage_key", &self.salvage_key) + .field("completeness", &self.completeness) + .field("omitted_count", &self.omitted_count) + .finish() + } +} +impl RecoverSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecoverSession"; +} +::buffa::impl_default_instance!(RecoverSession); +impl ::buffa::MessageName for RecoverSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RecoverSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RecoverSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecoverSession"; +} +impl ::buffa::Message for RecoverSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.execution_plan.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.execution_plan.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.workspace.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.workspace.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.execution_plan.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.execution_plan.write_to(__cache, buf); + } + if self.workspace.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.workspace.write_to(__cache, buf); + } + ::buffa::types::put_string_field(4u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(8u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(9u32, self.omitted_count, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.execution_plan.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.workspace.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_boundary.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.salvage_key, buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.omitted_count = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_plan = ::buffa::MessageField::none(); + self.workspace = ::buffa::MessageField::none(); + self.source_session_id.clear(); + self.source_boundary = ::buffa::MessageField::none(); + self.source_digest = ::buffa::MessageField::none(); + self.salvage_key.clear(); + self.completeness = ::buffa::EnumValue::from(0); + self.omitted_count = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecoverSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECOVER_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RecoverSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.__view.rs new file mode 100644 index 0000000000..c7ef5bf0c5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.__view.rs @@ -0,0 +1,526 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto + +/// RejectProviderToolIntent records a refused provider tool intent, producing +/// \[ProviderToolIntentRejected\]. +/// +/// Write precondition Any: the provider already emitted it, and no lifecycle +/// state can retract that. +/// +/// The raw emission is stored as an artifact before this command is issued, for +/// the same reason captured command output is: a decider that must write an +/// unbounded attacker-shaped payload before it can append has an append latency +/// set by the worst input it ever received. +#[derive(Clone, Debug, Default)] +pub struct RejectProviderToolIntentView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `rejection_id` + pub rejection_id: &'a str, + /// Field 3: `message_id` + pub message_id: &'a str, + /// Field 4: `turn_id` + pub turn_id: &'a str, + /// Field 5: `reason` + pub reason: ::buffa::EnumValue, + /// Field 6: `claimed_tool_call_id` + pub claimed_tool_call_id: ::core::option::Option<&'a str>, + /// Field 7: `claimed_tool_name` + pub claimed_tool_name: ::core::option::Option<&'a str>, + /// Field 8: `raw_intent` + pub raw_intent: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + /// Field 9: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RejectProviderToolIntentView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `rejection_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_rejection_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `message_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RejectProviderToolIntentView<'a> { + type Owned = super::super::RejectProviderToolIntent; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.rejection_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.claimed_tool_call_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.claimed_tool_name = Some(::buffa::types::borrow_str(&mut cur)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.raw_intent.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.raw_intent = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RejectProviderToolIntent, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RejectProviderToolIntent, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RejectProviderToolIntent { + session_id: self.session_id.to_string(), + rejection_id: self.rejection_id.to_string(), + message_id: self.message_id.to_string(), + turn_id: self.turn_id.to_string(), + reason: self.reason, + claimed_tool_call_id: self.claimed_tool_call_id.map(|s| s.to_string()), + claimed_tool_name: self.claimed_tool_name.map(|s| s.to_string()), + raw_intent: match self.raw_intent.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RejectProviderToolIntentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.rejection_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.claimed_tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.claimed_tool_name { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.raw_intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.rejection_id, buf); + ::buffa::types::put_string_field(3u32, &self.message_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.claimed_tool_call_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.claimed_tool_name { + ::buffa::types::put_string_field(7u32, v, buf); + } + if self.raw_intent.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.raw_intent.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(9u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RejectProviderToolIntentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("rejectionId", self.rejection_id)?; + } + { + __map.serialize_entry("messageId", self.message_id)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.claimed_tool_call_id { + __map.serialize_entry("claimedToolCallId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.claimed_tool_name { + __map.serialize_entry("claimedToolName", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.raw_intent.as_option() { + __map.serialize_entry("rawIntent", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RejectProviderToolIntentView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RejectProviderToolIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RejectProviderToolIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RejectProviderToolIntent"; +} +::buffa::impl_default_view_instance!(RejectProviderToolIntentView); +::buffa::impl_view_reborrow!(RejectProviderToolIntentView); +/** Self-contained, `'static` owned view of a `RejectProviderToolIntent` message. + + Wraps [`::buffa::OwnedView`]`<`[`RejectProviderToolIntentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RejectProviderToolIntentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RejectProviderToolIntentOwnedView( + ::buffa::OwnedView>, +); +impl RejectProviderToolIntentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RejectProviderToolIntentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RejectProviderToolIntentOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RejectProviderToolIntent, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RejectProviderToolIntentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RejectProviderToolIntentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RejectProviderToolIntentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RejectProviderToolIntent { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `rejection_id` + #[must_use] + pub fn rejection_id(&self) -> &'_ str { + self.0.reborrow().rejection_id + } + /// Field 3: `message_id` + #[must_use] + pub fn message_id(&self) -> &'_ str { + self.0.reborrow().message_id + } + /// Field 4: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Field 5: `reason` + #[must_use] + pub fn reason( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Field 6: `claimed_tool_call_id` + #[must_use] + pub fn claimed_tool_call_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().claimed_tool_call_id + } + /// Field 7: `claimed_tool_name` + #[must_use] + pub fn claimed_tool_name(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().claimed_tool_name + } + /// Field 8: `raw_intent` + #[must_use] + pub fn raw_intent( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().raw_intent + } + /// Field 9: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RejectProviderToolIntentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RejectProviderToolIntentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RejectProviderToolIntentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RejectProviderToolIntentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RejectProviderToolIntent { + type View<'a> = RejectProviderToolIntentView<'a>; + type ViewHandle = RejectProviderToolIntentOwnedView; +} +impl ::serde::Serialize for RejectProviderToolIntentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.rs new file mode 100644 index 0000000000..29909a9eb5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reject_provider_tool_intent.rs @@ -0,0 +1,335 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reject_provider_tool_intent.proto + +/// RejectProviderToolIntent records a refused provider tool intent, producing +/// \[ProviderToolIntentRejected\]. +/// +/// Write precondition Any: the provider already emitted it, and no lifecycle +/// state can retract that. +/// +/// The raw emission is stored as an artifact before this command is issued, for +/// the same reason captured command output is: a decider that must write an +/// unbounded attacker-shaped payload before it can append has an append latency +/// set by the worst input it ever received. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RejectProviderToolIntent { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `rejection_id` + #[serde( + rename = "rejectionId", + alias = "rejection_id", + with = "::buffa::json_helpers::proto_string" + )] + pub rejection_id: ::buffa::alloc::string::String, + /// Field 3: `message_id` + #[serde( + rename = "messageId", + alias = "message_id", + with = "::buffa::json_helpers::proto_string" + )] + pub message_id: ::buffa::alloc::string::String, + /// Field 4: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Field 5: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Field 6: `claimed_tool_call_id` + #[serde( + rename = "claimedToolCallId", + alias = "claimed_tool_call_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub claimed_tool_call_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 7: `claimed_tool_name` + #[serde( + rename = "claimedToolName", + alias = "claimed_tool_name", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub claimed_tool_name: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 8: `raw_intent` + #[serde( + rename = "rawIntent", + alias = "raw_intent", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub raw_intent: ::buffa::MessageField>, + /// Field 9: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for RejectProviderToolIntent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RejectProviderToolIntent") + .field("session_id", &self.session_id) + .field("rejection_id", &self.rejection_id) + .field("message_id", &self.message_id) + .field("turn_id", &self.turn_id) + .field("reason", &self.reason) + .field("claimed_tool_call_id", &self.claimed_tool_call_id) + .field("claimed_tool_name", &self.claimed_tool_name) + .field("raw_intent", &self.raw_intent) + .field("detail", &self.detail) + .finish() + } +} +impl RejectProviderToolIntent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RejectProviderToolIntent"; +} +impl RejectProviderToolIntent { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::claimed_tool_call_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_claimed_tool_call_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.claimed_tool_call_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::claimed_tool_name`] to `Some(value)`, consuming and returning `self`. + pub fn with_claimed_tool_name( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.claimed_tool_name = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RejectProviderToolIntent); +impl ::buffa::MessageName for RejectProviderToolIntent { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RejectProviderToolIntent"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RejectProviderToolIntent"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RejectProviderToolIntent"; +} +impl ::buffa::Message for RejectProviderToolIntent { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.rejection_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.claimed_tool_call_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.claimed_tool_name { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.raw_intent.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_intent.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.rejection_id, buf); + ::buffa::types::put_string_field(3u32, &self.message_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + ::buffa::types::put_int32_field(5u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.claimed_tool_call_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.claimed_tool_name { + ::buffa::types::put_string_field(7u32, v, buf); + } + if self.raw_intent.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.raw_intent.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(9u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.rejection_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .claimed_tool_call_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .claimed_tool_name + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.raw_intent.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.rejection_id.clear(); + self.message_id.clear(); + self.turn_id.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.claimed_tool_call_id = ::core::option::Option::None; + self.claimed_tool_name = ::core::option::Option::None; + self.raw_intent = ::buffa::MessageField::none(); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RejectProviderToolIntent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REJECT_PROVIDER_TOOL_INTENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RejectProviderToolIntent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.__view.rs new file mode 100644 index 0000000000..110ccf4dbf --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.__view.rs @@ -0,0 +1,283 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/rename_session.proto + +/// RenameSession changes the session's display name, recording +/// \[SessionRenamed\]. Reversible organization state, unlike the terminal +/// HideSession. +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct RenameSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `display_name` + pub display_name: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RenameSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `display_name` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_display_name(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RenameSessionView<'a> { + type Owned = super::super::RenameSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.display_name = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RenameSession { + session_id: self.session_id.to_string(), + display_name: self.display_name.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RenameSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.display_name) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.display_name, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RenameSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("displayName", self.display_name)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RenameSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RenameSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RenameSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RenameSession"; +} +::buffa::impl_default_view_instance!(RenameSessionView); +::buffa::impl_view_reborrow!(RenameSessionView); +/** Self-contained, `'static` owned view of a `RenameSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`RenameSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RenameSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RenameSessionOwnedView(::buffa::OwnedView>); +impl RenameSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RenameSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RenameSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RenameSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RenameSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RenameSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RenameSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RenameSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `display_name` + #[must_use] + pub fn display_name(&self) -> &'_ str { + self.0.reborrow().display_name + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RenameSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RenameSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RenameSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RenameSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RenameSession { + type View<'a> = RenameSessionView<'a>; + type ViewHandle = RenameSessionOwnedView; +} +impl ::serde::Serialize for RenameSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.rs new file mode 100644 index 0000000000..12c8736c5c --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rename_session.rs @@ -0,0 +1,132 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/rename_session.proto + +/// RenameSession changes the session's display name, recording +/// \[SessionRenamed\]. Reversible organization state, unlike the terminal +/// HideSession. +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RenameSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `display_name` + #[serde( + rename = "displayName", + alias = "display_name", + with = "::buffa::json_helpers::proto_string" + )] + pub display_name: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for RenameSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RenameSession") + .field("session_id", &self.session_id) + .field("display_name", &self.display_name) + .finish() + } +} +impl RenameSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RenameSession"; +} +::buffa::impl_default_instance!(RenameSession); +impl ::buffa::MessageName for RenameSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RenameSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RenameSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RenameSession"; +} +impl ::buffa::Message for RenameSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.display_name) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.display_name, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.display_name, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.display_name.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RenameSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RENAME_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RenameSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.__view.rs new file mode 100644 index 0000000000..02cfdab1d1 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.__view.rs @@ -0,0 +1,320 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/request_operation_cancellation.proto + +/// RequestOperationCancellation asks for an in-flight side effect to stop, +/// recording \[OperationCancellationRequested\]. Asking is not settling: the +/// operation still needs a recorded outcome before it leaves the ledger. +/// +/// Write precondition At: rejected if the operation is already terminal. +#[derive(Clone, Debug, Default)] +pub struct RequestOperationCancellationView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `operation_id` + pub operation_id: &'a str, + /// Field 3: `reason` + pub reason: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RequestOperationCancellationView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RequestOperationCancellationView<'a> { + type Owned = super::super::RequestOperationCancellation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.reason = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::RequestOperationCancellation, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::RequestOperationCancellation, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RequestOperationCancellation { + session_id: self.session_id.to_string(), + operation_id: self.operation_id.to_string(), + reason: self.reason.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RequestOperationCancellationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RequestOperationCancellationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + if let ::core::option::Option::Some(__v) = self.reason { + __map.serialize_entry("reason", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RequestOperationCancellationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RequestOperationCancellation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RequestOperationCancellation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestOperationCancellation"; +} +::buffa::impl_default_view_instance!(RequestOperationCancellationView); +::buffa::impl_view_reborrow!(RequestOperationCancellationView); +/** Self-contained, `'static` owned view of a `RequestOperationCancellation` message. + + Wraps [`::buffa::OwnedView`]`<`[`RequestOperationCancellationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RequestOperationCancellationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RequestOperationCancellationOwnedView( + ::buffa::OwnedView>, +); +impl RequestOperationCancellationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestOperationCancellationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestOperationCancellationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RequestOperationCancellation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestOperationCancellationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RequestOperationCancellationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RequestOperationCancellationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RequestOperationCancellation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Field 3: `reason` + #[must_use] + pub fn reason(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RequestOperationCancellationOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + RequestOperationCancellationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RequestOperationCancellationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef< + ::buffa::OwnedView>, +> for RequestOperationCancellationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RequestOperationCancellation { + type View<'a> = RequestOperationCancellationView<'a>; + type ViewHandle = RequestOperationCancellationOwnedView; +} +impl ::serde::Serialize for RequestOperationCancellationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.rs new file mode 100644 index 0000000000..3dcfa6efb5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_operation_cancellation.rs @@ -0,0 +1,165 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/request_operation_cancellation.proto + +/// RequestOperationCancellation asks for an in-flight side effect to stop, +/// recording \[OperationCancellationRequested\]. Asking is not settling: the +/// operation still needs a recorded outcome before it leaves the ledger. +/// +/// Write precondition At: rejected if the operation is already terminal. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RequestOperationCancellation { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Field 3: `reason` + #[serde(rename = "reason", skip_serializing_if = "::core::option::Option::is_none")] + pub reason: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for RequestOperationCancellation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RequestOperationCancellation") + .field("session_id", &self.session_id) + .field("operation_id", &self.operation_id) + .field("reason", &self.reason) + .finish() + } +} +impl RequestOperationCancellation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestOperationCancellation"; +} +impl RequestOperationCancellation { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::reason`] to `Some(value)`, consuming and returning `self`. + pub fn with_reason( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.reason = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RequestOperationCancellation); +impl ::buffa::MessageName for RequestOperationCancellation { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RequestOperationCancellation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RequestOperationCancellation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestOperationCancellation"; +} +impl ::buffa::Message for RequestOperationCancellation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if let Some(ref v) = self.reason { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if let Some(ref v) = self.reason { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.reason.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.operation_id.clear(); + self.reason = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for RequestOperationCancellation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REQUEST_OPERATION_CANCELLATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestOperationCancellation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.__view.rs new file mode 100644 index 0000000000..2228e38534 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.__view.rs @@ -0,0 +1,464 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/request_tool_call.proto + +/// RequestToolCall records that the model asked for a tool, recording +/// \[ToolCallRequested\]. +/// +/// Write precondition Any: this is the aggregate's highest-volume path and it +/// commutes with everything else, so it never coordinates and never retries. +#[derive(Clone, Debug, Default)] +pub struct RequestToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Identity of the request. Approval, denial, and start all join on it. + /// + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Retry identity of this execution of the call. The terminal outcome joins + /// on it, so a re-execution settles the attempt it belongs to. + /// + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `tool_name` + pub tool_name: &'a str, + /// Field 5: `input_json` + pub input_json: &'a str, + /// Field 6: `parent_tool_use_id` + pub parent_tool_use_id: ::core::option::Option<&'a str>, + /// The ledger operation guarding this call's side effect, when it reserves one. + /// + /// Field 7: `operation_id` + pub operation_id: ::core::option::Option<&'a str>, + /// Field 8: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RequestToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `tool_name` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_name(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `input_json` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_input_json(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 32u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RequestToolCallView<'a> { + type Owned = super::super::RequestToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_name = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.input_json = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.parent_tool_use_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 32u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RequestToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + tool_name: self.tool_name.to_string(), + input_json: self.input_json.to_string(), + parent_tool_use_id: self.parent_tool_use_id.map(|s| s.to_string()), + operation_id: self.operation_id.map(|s| s.to_string()), + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RequestToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.input_json) as u64; + if let Some(ref v) = self.parent_tool_use_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.tool_name, buf); + ::buffa::types::put_string_field(5u32, &self.input_json, buf); + if let Some(ref v) = self.parent_tool_use_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + ::buffa::types::put_string_field(8u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RequestToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("toolName", self.tool_name)?; + } + { + __map.serialize_entry("inputJson", self.input_json)?; + } + if let ::core::option::Option::Some(__v) = self.parent_tool_use_id { + __map.serialize_entry("parentToolUseId", __v)?; + } + if let ::core::option::Option::Some(__v) = self.operation_id { + __map.serialize_entry("operationId", __v)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RequestToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RequestToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RequestToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestToolCall"; +} +::buffa::impl_default_view_instance!(RequestToolCallView); +::buffa::impl_view_reborrow!(RequestToolCallView); +/** Self-contained, `'static` owned view of a `RequestToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`RequestToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RequestToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RequestToolCallOwnedView(::buffa::OwnedView>); +impl RequestToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestToolCallOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RequestToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RequestToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RequestToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RequestToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RequestToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Identity of the request. Approval, denial, and start all join on it. + /// + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Retry identity of this execution of the call. The terminal outcome joins + /// on it, so a re-execution settles the attempt it belongs to. + /// + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `tool_name` + #[must_use] + pub fn tool_name(&self) -> &'_ str { + self.0.reborrow().tool_name + } + /// Field 5: `input_json` + #[must_use] + pub fn input_json(&self) -> &'_ str { + self.0.reborrow().input_json + } + /// Field 6: `parent_tool_use_id` + #[must_use] + pub fn parent_tool_use_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().parent_tool_use_id + } + /// The ledger operation guarding this call's side effect, when it reserves one. + /// + /// Field 7: `operation_id` + #[must_use] + pub fn operation_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().operation_id + } + /// Field 8: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RequestToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RequestToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RequestToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RequestToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RequestToolCall { + type View<'a> = RequestToolCallView<'a>; + type ViewHandle = RequestToolCallOwnedView; +} +impl ::serde::Serialize for RequestToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.rs new file mode 100644 index 0000000000..a3b23f31c5 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.request_tool_call.rs @@ -0,0 +1,288 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/request_tool_call.proto + +/// RequestToolCall records that the model asked for a tool, recording +/// \[ToolCallRequested\]. +/// +/// Write precondition Any: this is the aggregate's highest-volume path and it +/// commutes with everything else, so it never coordinates and never retries. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RequestToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Identity of the request. Approval, denial, and start all join on it. + /// + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Retry identity of this execution of the call. The terminal outcome joins + /// on it, so a re-execution settles the attempt it belongs to. + /// + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `tool_name` + #[serde( + rename = "toolName", + alias = "tool_name", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_name: ::buffa::alloc::string::String, + /// Field 5: `input_json` + #[serde( + rename = "inputJson", + alias = "input_json", + with = "::buffa::json_helpers::proto_string" + )] + pub input_json: ::buffa::alloc::string::String, + /// Field 6: `parent_tool_use_id` + #[serde( + rename = "parentToolUseId", + alias = "parent_tool_use_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub parent_tool_use_id: ::core::option::Option<::buffa::alloc::string::String>, + /// The ledger operation guarding this call's side effect, when it reserves one. + /// + /// Field 7: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub operation_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Field 8: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for RequestToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RequestToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("tool_name", &self.tool_name) + .field("input_json", &self.input_json) + .field("parent_tool_use_id", &self.parent_tool_use_id) + .field("operation_id", &self.operation_id) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl RequestToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestToolCall"; +} +impl RequestToolCall { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::parent_tool_use_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_parent_tool_use_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.parent_tool_use_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::operation_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_operation_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.operation_id = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(RequestToolCall); +impl ::buffa::MessageName for RequestToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RequestToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RequestToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestToolCall"; +} +impl ::buffa::Message for RequestToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_name) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.input_json) as u64; + if let Some(ref v) = self.parent_tool_use_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.operation_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.tool_name, buf); + ::buffa::types::put_string_field(5u32, &self.input_json, buf); + if let Some(ref v) = self.parent_tool_use_id { + ::buffa::types::put_string_field(6u32, v, buf); + } + if let Some(ref v) = self.operation_id { + ::buffa::types::put_string_field(7u32, v, buf); + } + ::buffa::types::put_string_field(8u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_name, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.input_json, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .parent_tool_use_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .operation_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.tool_name.clear(); + self.input_json.clear(); + self.parent_tool_use_id = ::core::option::Option::None; + self.operation_id = ::core::option::Option::None; + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RequestToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REQUEST_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RequestToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.__view.rs new file mode 100644 index 0000000000..2138a057e2 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.__view.rs @@ -0,0 +1,396 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reserve_operation.proto + +/// ReserveOperation claims an operation id and its request bytes before a side +/// effect runs, recording \[OperationReserved\]. +/// +/// Write precondition At: this is what makes reserve-and-check atomic. One +/// reservation per operation_id; a retry carrying different bytes under the same +/// id is a contract violation, not a duplicate (ADR#0035 facet 3). +#[derive(Clone, Debug, Default)] +pub struct ReserveOperationView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `operation_id` + pub operation_id: &'a str, + /// Digest of the request the id is reserved for, so a retry with different + /// bytes is refused instead of executed as if it were the same call. + /// + /// Field 3: `request_digest` + pub request_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 4: `operation_kind` + pub operation_kind: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReserveOperationView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `operation_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `request_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_request_digest(&self) -> bool { + self.request_digest.is_set() + } + /**Whether required field `operation_kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_operation_kind(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReserveOperationView<'a> { + type Owned = super::super::ReserveOperation; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.operation_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.request_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.request_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.operation_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReserveOperation { + session_id: self.session_id.to_string(), + operation_id: self.operation_id.to_string(), + request_digest: match self.request_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + operation_kind: self.operation_kind, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReserveOperationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.operation_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(4u32, self.operation_kind.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReserveOperationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("operationId", self.operation_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.request_digest.as_option() { + __map.serialize_entry("requestDigest", __v)?; + } + } + { + __map.serialize_entry("operationKind", &self.operation_kind)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReserveOperationView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReserveOperation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReserveOperation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReserveOperation"; +} +::buffa::impl_default_view_instance!(ReserveOperationView); +::buffa::impl_view_reborrow!(ReserveOperationView); +/** Self-contained, `'static` owned view of a `ReserveOperation` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReserveOperationView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReserveOperationView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReserveOperationOwnedView(::buffa::OwnedView>); +impl ReserveOperationOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReserveOperationOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReserveOperationOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReserveOperation, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReserveOperationOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReserveOperationView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReserveOperationView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReserveOperation { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `operation_id` + #[must_use] + pub fn operation_id(&self) -> &'_ str { + self.0.reborrow().operation_id + } + /// Digest of the request the id is reserved for, so a retry with different + /// bytes is refused instead of executed as if it were the same call. + /// + /// Field 3: `request_digest` + #[must_use] + pub fn request_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().request_digest + } + /// Field 4: `operation_kind` + #[must_use] + pub fn operation_kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().operation_kind + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReserveOperationOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReserveOperationOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReserveOperationOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReserveOperationOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReserveOperation { + type View<'a> = ReserveOperationView<'a>; + type ViewHandle = ReserveOperationOwnedView; +} +impl ::serde::Serialize for ReserveOperationOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.rs new file mode 100644 index 0000000000..fd858d2887 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.reserve_operation.rs @@ -0,0 +1,191 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/reserve_operation.proto + +/// ReserveOperation claims an operation id and its request bytes before a side +/// effect runs, recording \[OperationReserved\]. +/// +/// Write precondition At: this is what makes reserve-and-check atomic. One +/// reservation per operation_id; a retry carrying different bytes under the same +/// id is a contract violation, not a duplicate (ADR#0035 facet 3). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReserveOperation { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `operation_id` + #[serde( + rename = "operationId", + alias = "operation_id", + with = "::buffa::json_helpers::proto_string" + )] + pub operation_id: ::buffa::alloc::string::String, + /// Digest of the request the id is reserved for, so a retry with different + /// bytes is refused instead of executed as if it were the same call. + /// + /// Field 3: `request_digest` + #[serde(rename = "requestDigest", alias = "request_digest")] + pub request_digest: ::buffa::MessageField>, + /// Field 4: `operation_kind` + #[serde( + rename = "operationKind", + alias = "operation_kind", + with = "::buffa::json_helpers::proto_enum" + )] + pub operation_kind: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for ReserveOperation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReserveOperation") + .field("session_id", &self.session_id) + .field("operation_id", &self.operation_id) + .field("request_digest", &self.request_digest) + .field("operation_kind", &self.operation_kind) + .finish() + } +} +impl ReserveOperation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReserveOperation"; +} +::buffa::impl_default_instance!(ReserveOperation); +impl ::buffa::MessageName for ReserveOperation { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ReserveOperation"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ReserveOperation"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReserveOperation"; +} +impl ::buffa::Message for ReserveOperation { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.operation_id) as u64; + if self.request_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.request_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.operation_kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.operation_id, buf); + if self.request_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.request_digest.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(4u32, self.operation_kind.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.operation_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.request_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.operation_kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.operation_id.clear(); + self.request_digest = ::buffa::MessageField::none(); + self.operation_kind = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReserveOperation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RESERVE_OPERATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ReserveOperation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.__view.rs new file mode 100644 index 0000000000..ab904fcdd6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.__view.rs @@ -0,0 +1,526 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/resource_access.proto + +/// ResourceAccessRecord records what a tool call did to a namespace of +/// resources, as distinct from what content it read. +/// +/// It exists because ResourceObservation deliberately answers only one question. +/// An observation means content entered the model's context, and its digest is +/// what makes a later write checkable. A search that walks a directory of +/// sensitive filenames and returns none of their contents produces no +/// observation, correctly, and yet something happened that a compliance reviewer +/// has to be able to see: the agent learned that those files exist and what they +/// are called. +/// +/// The two must stay separate rather than merging into one weakened observation. +/// "Did the agent read this file" and "did the agent see this file's name" are +/// different questions with different answers and different consequences, and a +/// single record that means either makes both unanswerable. +/// +/// Records are per-scope, never per-path. That is the same volume argument that +/// keeps reads off their own event: a search can walk forty thousand paths, and +/// forty thousand facts appended to a log that is never truncated +/// (ADR#0035 facet 7) would make the dominant content of a session stream the +/// output of one grep. The scope plus the counts is what a reviewer needs to know +/// what was exposed; the path list itself, when it is worth keeping, goes out of +/// line as an artifact and is erasable like any other artifact while the counts +/// survive it. +#[derive(Clone, Debug, Default)] +pub struct ResourceAccessRecordView<'a> { + /// Field 1: `action` + pub action: ::buffa::EnumValue, + /// The namespace this access covered, as a URI prefix or a glob in the same URI + /// form as WorkspaceRef.uri. This is the extent of exposure, not a single + /// resource: a directory listing's scope is the directory, and a recursive + /// search's scope is its root. + /// + /// Field 2: `scope` + pub scope: &'a str, + /// Resources within scope the tool actually enumerated back to the caller. For + /// a search this is the hit count, which is the number that matters, since + /// knowing that four files in a secrets directory matched "password" is a + /// different disclosure from knowing the directory has four hundred files. + /// + /// Field 3: `matched` + pub matched: u64, + /// Resources within scope the tool traversed to produce that answer. Recorded + /// apart from `matched` because traversal is itself access to a namespace: a + /// filter that rejected a path still required reading the path's name. + /// + /// Field 4: `traversed` + pub traversed: u64, + /// True when the tool covered its scope entirely. False when it stopped at a + /// result limit, a depth limit, or a timeout, so a reviewer never reads a + /// truncated enumeration as a complete inventory of what was exposed. + /// + /// Field 5: `complete` + pub complete: bool, + /// Claim-check to the enumerated resource identifiers, when they were kept. + /// + /// Unset is ordinary and does not weaken the record: the counts and the scope + /// stand on their own. It is a claim-check rather than a repeated string for + /// the volume reason above, and being an artifact is also what makes the list + /// erasable under a deletion request while leaving the audit fact that an + /// enumeration happened permanently intact. + /// + /// Field 6: `enumerated` + pub enumerated: ::buffa::MessageFieldView< + super::super::__buffa::view::ArtifactRefView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ResourceAccessRecordView<'a> { + /**Whether required field `action` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_action(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `scope` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_scope(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `matched` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_matched(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `traversed` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_traversed(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `complete` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_complete(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ResourceAccessRecordView<'a> { + type Owned = super::super::ResourceAccessRecord; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.scope = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.matched = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.traversed = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.complete = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.enumerated.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.enumerated = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ResourceAccessRecord, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ResourceAccessRecord, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ResourceAccessRecord { + action: self.action, + scope: self.scope.to_string(), + matched: self.matched, + traversed: self.traversed, + complete: self.complete, + enumerated: match self.enumerated.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ArtifactRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ResourceAccessRecordView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.scope) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.matched) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.traversed) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.enumerated.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.enumerated.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.action.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.scope, buf); + ::buffa::types::put_uint64_field(3u32, self.matched, buf); + ::buffa::types::put_uint64_field(4u32, self.traversed, buf); + ::buffa::types::put_bool_field(5u32, self.complete, buf); + if self.enumerated.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.enumerated.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ResourceAccessRecordView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("action", &self.action)?; + } + { + __map.serialize_entry("scope", self.scope)?; + } + { + __map + .serialize_entry( + "matched", + &::buffa::json_helpers::ProtoJson(&self.matched), + )?; + } + { + __map + .serialize_entry( + "traversed", + &::buffa::json_helpers::ProtoJson(&self.traversed), + )?; + } + { + __map.serialize_entry("complete", &self.complete)?; + } + { + if let ::core::option::Option::Some(__v) = self.enumerated.as_option() { + __map.serialize_entry("enumerated", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ResourceAccessRecordView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ResourceAccessRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ResourceAccessRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ResourceAccessRecord"; +} +::buffa::impl_default_view_instance!(ResourceAccessRecordView); +::buffa::impl_view_reborrow!(ResourceAccessRecordView); +/** Self-contained, `'static` owned view of a `ResourceAccessRecord` message. + + Wraps [`::buffa::OwnedView`]`<`[`ResourceAccessRecordView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ResourceAccessRecordView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ResourceAccessRecordOwnedView( + ::buffa::OwnedView>, +); +impl ResourceAccessRecordOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ResourceAccessRecordOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ResourceAccessRecordOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ResourceAccessRecord, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ResourceAccessRecordOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ResourceAccessRecordView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ResourceAccessRecordView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ResourceAccessRecord { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `action` + #[must_use] + pub fn action(&self) -> ::buffa::EnumValue { + self.0.reborrow().action + } + /// The namespace this access covered, as a URI prefix or a glob in the same URI + /// form as WorkspaceRef.uri. This is the extent of exposure, not a single + /// resource: a directory listing's scope is the directory, and a recursive + /// search's scope is its root. + /// + /// Field 2: `scope` + #[must_use] + pub fn scope(&self) -> &'_ str { + self.0.reborrow().scope + } + /// Resources within scope the tool actually enumerated back to the caller. For + /// a search this is the hit count, which is the number that matters, since + /// knowing that four files in a secrets directory matched "password" is a + /// different disclosure from knowing the directory has four hundred files. + /// + /// Field 3: `matched` + #[must_use] + pub fn matched(&self) -> u64 { + self.0.reborrow().matched + } + /// Resources within scope the tool traversed to produce that answer. Recorded + /// apart from `matched` because traversal is itself access to a namespace: a + /// filter that rejected a path still required reading the path's name. + /// + /// Field 4: `traversed` + #[must_use] + pub fn traversed(&self) -> u64 { + self.0.reborrow().traversed + } + /// True when the tool covered its scope entirely. False when it stopped at a + /// result limit, a depth limit, or a timeout, so a reviewer never reads a + /// truncated enumeration as a complete inventory of what was exposed. + /// + /// Field 5: `complete` + #[must_use] + pub fn complete(&self) -> bool { + self.0.reborrow().complete + } + /// Claim-check to the enumerated resource identifiers, when they were kept. + /// + /// Unset is ordinary and does not weaken the record: the counts and the scope + /// stand on their own. It is a claim-check rather than a repeated string for + /// the volume reason above, and being an artifact is also what makes the list + /// erasable under a deletion request while leaving the audit fact that an + /// enumeration happened permanently intact. + /// + /// Field 6: `enumerated` + #[must_use] + pub fn enumerated( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().enumerated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ResourceAccessRecordOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ResourceAccessRecordOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ResourceAccessRecordOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ResourceAccessRecordOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ResourceAccessRecord { + type View<'a> = ResourceAccessRecordView<'a>; + type ViewHandle = ResourceAccessRecordOwnedView; +} +impl ::serde::Serialize for ResourceAccessRecordOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.rs new file mode 100644 index 0000000000..b4e6410b01 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.resource_access.rs @@ -0,0 +1,503 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/resource_access.proto + +/// ResourceAction is what was done to a namespace, in the terms an access policy +/// is written in. +/// +/// The distinction the taxonomy exists for is between the actions that expose +/// names and the actions that expose or alter content. LIST and SEARCH disclose +/// a namespace. READ discloses content. The mutating actions change it. A policy +/// that cannot separate those cannot express "this agent may find files here but +/// may not open them", which is a rule real deployments have. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ResourceAction { + RESOURCE_ACTION_UNSPECIFIED = 0i32, + /// Enumerated the names within a scope, without reading contents. + RESOURCE_ACTION_LIST = 1i32, + /// Matched contents within a scope and returned locations or excerpts. Content + /// that actually entered the model's context is separately a + /// ResourceObservation; a search that returned only paths is not. + RESOURCE_ACTION_SEARCH = 2i32, + /// Read content. Paired with a ResourceObservation carrying the digest. + RESOURCE_ACTION_READ = 3i32, + /// Created or overwrote content. + RESOURCE_ACTION_WRITE = 4i32, + /// Modified existing content in place. + RESOURCE_ACTION_EDIT = 5i32, + /// Removed resources. + RESOURCE_ACTION_DELETE = 6i32, + /// Moved or renamed resources. + RESOURCE_ACTION_RENAME = 7i32, + /// Duplicated resources to a new location. + RESOURCE_ACTION_COPY = 8i32, + /// Changed permissions, ownership, or other metadata without changing content. + RESOURCE_ACTION_CHANGE_METADATA = 9i32, + /// Executed a resource as a program. + RESOURCE_ACTION_EXECUTE = 10i32, +} +impl ResourceAction { + ///Idiomatic alias for [`Self::RESOURCE_ACTION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RESOURCE_ACTION_UNSPECIFIED; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_LIST`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const List: Self = Self::RESOURCE_ACTION_LIST; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_SEARCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Search: Self = Self::RESOURCE_ACTION_SEARCH; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_READ`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Read: Self = Self::RESOURCE_ACTION_READ; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_WRITE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Write: Self = Self::RESOURCE_ACTION_WRITE; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_EDIT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Edit: Self = Self::RESOURCE_ACTION_EDIT; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_DELETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Delete: Self = Self::RESOURCE_ACTION_DELETE; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_RENAME`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Rename: Self = Self::RESOURCE_ACTION_RENAME; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_COPY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Copy: Self = Self::RESOURCE_ACTION_COPY; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_CHANGE_METADATA`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChangeMetadata: Self = Self::RESOURCE_ACTION_CHANGE_METADATA; + ///Idiomatic alias for [`Self::RESOURCE_ACTION_EXECUTE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Execute: Self = Self::RESOURCE_ACTION_EXECUTE; +} +impl ::core::default::Default for ResourceAction { + fn default() -> Self { + Self::RESOURCE_ACTION_UNSPECIFIED + } +} +impl ::serde::Serialize for ResourceAction { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ResourceAction { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ResourceAction; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(ResourceAction) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ResourceAction { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ResourceAction { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_LIST), + 2i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_SEARCH), + 3i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_READ), + 4i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_WRITE), + 5i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_EDIT), + 6i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_DELETE), + 7i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_RENAME), + 8i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_COPY), + 9i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_CHANGE_METADATA), + 10i32 => ::core::option::Option::Some(Self::RESOURCE_ACTION_EXECUTE), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RESOURCE_ACTION_UNSPECIFIED => "RESOURCE_ACTION_UNSPECIFIED", + Self::RESOURCE_ACTION_LIST => "RESOURCE_ACTION_LIST", + Self::RESOURCE_ACTION_SEARCH => "RESOURCE_ACTION_SEARCH", + Self::RESOURCE_ACTION_READ => "RESOURCE_ACTION_READ", + Self::RESOURCE_ACTION_WRITE => "RESOURCE_ACTION_WRITE", + Self::RESOURCE_ACTION_EDIT => "RESOURCE_ACTION_EDIT", + Self::RESOURCE_ACTION_DELETE => "RESOURCE_ACTION_DELETE", + Self::RESOURCE_ACTION_RENAME => "RESOURCE_ACTION_RENAME", + Self::RESOURCE_ACTION_COPY => "RESOURCE_ACTION_COPY", + Self::RESOURCE_ACTION_CHANGE_METADATA => "RESOURCE_ACTION_CHANGE_METADATA", + Self::RESOURCE_ACTION_EXECUTE => "RESOURCE_ACTION_EXECUTE", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RESOURCE_ACTION_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_UNSPECIFIED) + } + "RESOURCE_ACTION_LIST" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_LIST) + } + "RESOURCE_ACTION_SEARCH" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_SEARCH) + } + "RESOURCE_ACTION_READ" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_READ) + } + "RESOURCE_ACTION_WRITE" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_WRITE) + } + "RESOURCE_ACTION_EDIT" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_EDIT) + } + "RESOURCE_ACTION_DELETE" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_DELETE) + } + "RESOURCE_ACTION_RENAME" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_RENAME) + } + "RESOURCE_ACTION_COPY" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_COPY) + } + "RESOURCE_ACTION_CHANGE_METADATA" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_CHANGE_METADATA) + } + "RESOURCE_ACTION_EXECUTE" => { + ::core::option::Option::Some(Self::RESOURCE_ACTION_EXECUTE) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RESOURCE_ACTION_UNSPECIFIED, + Self::RESOURCE_ACTION_LIST, + Self::RESOURCE_ACTION_SEARCH, + Self::RESOURCE_ACTION_READ, + Self::RESOURCE_ACTION_WRITE, + Self::RESOURCE_ACTION_EDIT, + Self::RESOURCE_ACTION_DELETE, + Self::RESOURCE_ACTION_RENAME, + Self::RESOURCE_ACTION_COPY, + Self::RESOURCE_ACTION_CHANGE_METADATA, + Self::RESOURCE_ACTION_EXECUTE, + ] + } +} +/// ResourceAccessRecord records what a tool call did to a namespace of +/// resources, as distinct from what content it read. +/// +/// It exists because ResourceObservation deliberately answers only one question. +/// An observation means content entered the model's context, and its digest is +/// what makes a later write checkable. A search that walks a directory of +/// sensitive filenames and returns none of their contents produces no +/// observation, correctly, and yet something happened that a compliance reviewer +/// has to be able to see: the agent learned that those files exist and what they +/// are called. +/// +/// The two must stay separate rather than merging into one weakened observation. +/// "Did the agent read this file" and "did the agent see this file's name" are +/// different questions with different answers and different consequences, and a +/// single record that means either makes both unanswerable. +/// +/// Records are per-scope, never per-path. That is the same volume argument that +/// keeps reads off their own event: a search can walk forty thousand paths, and +/// forty thousand facts appended to a log that is never truncated +/// (ADR#0035 facet 7) would make the dominant content of a session stream the +/// output of one grep. The scope plus the counts is what a reviewer needs to know +/// what was exposed; the path list itself, when it is worth keeping, goes out of +/// line as an artifact and is erasable like any other artifact while the counts +/// survive it. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ResourceAccessRecord { + /// Field 1: `action` + #[serde(rename = "action", with = "::buffa::json_helpers::proto_enum")] + pub action: ::buffa::EnumValue, + /// The namespace this access covered, as a URI prefix or a glob in the same URI + /// form as WorkspaceRef.uri. This is the extent of exposure, not a single + /// resource: a directory listing's scope is the directory, and a recursive + /// search's scope is its root. + /// + /// Field 2: `scope` + #[serde(rename = "scope", with = "::buffa::json_helpers::proto_string")] + pub scope: ::buffa::alloc::string::String, + /// Resources within scope the tool actually enumerated back to the caller. For + /// a search this is the hit count, which is the number that matters, since + /// knowing that four files in a secrets directory matched "password" is a + /// different disclosure from knowing the directory has four hundred files. + /// + /// Field 3: `matched` + #[serde(rename = "matched", with = "::buffa::json_helpers::uint64")] + pub matched: u64, + /// Resources within scope the tool traversed to produce that answer. Recorded + /// apart from `matched` because traversal is itself access to a namespace: a + /// filter that rejected a path still required reading the path's name. + /// + /// Field 4: `traversed` + #[serde(rename = "traversed", with = "::buffa::json_helpers::uint64")] + pub traversed: u64, + /// True when the tool covered its scope entirely. False when it stopped at a + /// result limit, a depth limit, or a timeout, so a reviewer never reads a + /// truncated enumeration as a complete inventory of what was exposed. + /// + /// Field 5: `complete` + #[serde(rename = "complete", with = "::buffa::json_helpers::proto_bool")] + pub complete: bool, + /// Claim-check to the enumerated resource identifiers, when they were kept. + /// + /// Unset is ordinary and does not weaken the record: the counts and the scope + /// stand on their own. It is a claim-check rather than a repeated string for + /// the volume reason above, and being an artifact is also what makes the list + /// erasable under a deletion request while leaving the audit fact that an + /// enumeration happened permanently intact. + /// + /// Field 6: `enumerated` + #[serde( + rename = "enumerated", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub enumerated: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for ResourceAccessRecord { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ResourceAccessRecord") + .field("action", &self.action) + .field("scope", &self.scope) + .field("matched", &self.matched) + .field("traversed", &self.traversed) + .field("complete", &self.complete) + .field("enumerated", &self.enumerated) + .finish() + } +} +impl ResourceAccessRecord { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ResourceAccessRecord"; +} +::buffa::impl_default_instance!(ResourceAccessRecord); +impl ::buffa::MessageName for ResourceAccessRecord { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "ResourceAccessRecord"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.ResourceAccessRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ResourceAccessRecord"; +} +impl ::buffa::Message for ResourceAccessRecord { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.action.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.scope) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.matched) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.traversed) as u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + if self.enumerated.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.enumerated.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.action.to_i32(), buf); + ::buffa::types::put_string_field(2u32, &self.scope, buf); + ::buffa::types::put_uint64_field(3u32, self.matched, buf); + ::buffa::types::put_uint64_field(4u32, self.traversed, buf); + ::buffa::types::put_bool_field(5u32, self.complete, buf); + if self.enumerated.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.enumerated.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.action = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.scope, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.matched = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.traversed = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.complete = ::buffa::types::decode_bool(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.enumerated.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.action = ::buffa::EnumValue::from(0); + self.scope.clear(); + self.matched = 0u64; + self.traversed = 0u64; + self.complete = false; + self.enumerated = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ResourceAccessRecord { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RESOURCE_ACCESS_RECORD_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.ResourceAccessRecord", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.__view.rs new file mode 100644 index 0000000000..fe1b90f1a7 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.__view.rs @@ -0,0 +1,365 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/rewind_session.proto + +/// RewindSession moves the effective-history boundary back, recording +/// \[SessionRewound\]. It masks what later turns and readers see; it never +/// un-applies a fact, because work that really ran still has to be reconcilable. +/// +/// Write precondition At: keep_through must lie within the log the decision was +/// taken against. +#[derive(Clone, Debug, Default)] +pub struct RewindSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// This session's own ordinal that stays effective; everything after it is masked. + /// + /// Field 2: `keep_through` + pub keep_through: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Field 3: `reason` + pub reason: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> RewindSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `keep_through` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_keep_through(&self) -> bool { + self.keep_through.is_set() + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for RewindSessionView<'a> { + type Owned = super::super::RewindSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.keep_through.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.keep_through = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::RewindSession { + session_id: self.session_id.to_string(), + keep_through: match self.keep_through.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + reason: self.reason, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for RewindSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.keep_through.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.reason.to_i32(), buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for RewindSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.keep_through.as_option() { + __map.serialize_entry("keepThrough", __v)?; + } + } + { + __map.serialize_entry("reason", &self.reason)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for RewindSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RewindSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RewindSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RewindSession"; +} +::buffa::impl_default_view_instance!(RewindSessionView); +::buffa::impl_view_reborrow!(RewindSessionView); +/** Self-contained, `'static` owned view of a `RewindSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`RewindSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`RewindSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct RewindSessionOwnedView(::buffa::OwnedView>); +impl RewindSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RewindSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RewindSessionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::RewindSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + RewindSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`RewindSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &RewindSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::RewindSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// This session's own ordinal that stays effective; everything after it is masked. + /// + /// Field 2: `keep_through` + #[must_use] + pub fn keep_through( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().keep_through + } + /// Field 3: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for RewindSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + RewindSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: RewindSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for RewindSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::RewindSession { + type View<'a> = RewindSessionView<'a>; + type ViewHandle = RewindSessionOwnedView; +} +impl ::serde::Serialize for RewindSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.rs new file mode 100644 index 0000000000..96e22e6fd6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.rewind_session.rs @@ -0,0 +1,171 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/rewind_session.proto + +/// RewindSession moves the effective-history boundary back, recording +/// \[SessionRewound\]. It masks what later turns and readers see; it never +/// un-applies a fact, because work that really ran still has to be reconcilable. +/// +/// Write precondition At: keep_through must lie within the log the decision was +/// taken against. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct RewindSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// This session's own ordinal that stays effective; everything after it is masked. + /// + /// Field 2: `keep_through` + #[serde(rename = "keepThrough", alias = "keep_through")] + pub keep_through: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Field 3: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for RewindSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RewindSession") + .field("session_id", &self.session_id) + .field("keep_through", &self.keep_through) + .field("reason", &self.reason) + .finish() + } +} +impl RewindSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RewindSession"; +} +::buffa::impl_default_instance!(RewindSession); +impl ::buffa::MessageName for RewindSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "RewindSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.RewindSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.RewindSession"; +} +impl ::buffa::Message for RewindSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + if self.keep_through.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.keep_through.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + if self.keep_through.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.keep_through.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.reason.to_i32(), buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.keep_through.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.keep_through = ::buffa::MessageField::none(); + self.reason = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for RewindSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REWIND_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.RewindSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.__view.rs new file mode 100644 index 0000000000..504b056a20 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.__view.rs @@ -0,0 +1,566 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/session_recovered.proto + +/// SessionRecovered is the second event in the atomic +/// \[SessionStarted, SessionRecovered\] creation batch appended to a salvaged +/// session's subject under the NoStream precondition, making salvage creation +/// atomic and exactly-once (ADR#0035 facet 2). +/// +/// It exists as an event rather than only as a maintenance record because a +/// reader folding this stream alone must be able to tell that this session is a +/// copy of a damaged one. A projection is rebuilt from the stream, so provenance +/// that lived only in an operator-side journal would be lost on the next rebuild +/// and the session would then read as an ordinary session with a short history. +/// +/// This is not SessionForked. A fork inherits its source by reference within +/// context_prefix_boundary and depends on the source staying readable; a +/// recovery copies, because the source's readability is the thing that failed. +/// The copied events are this session's own events at this session's own +/// ordinals: source ordinals do not carry over, and source_boundary is +/// provenance, not an index into this stream. +#[derive(Clone, Debug, Default)] +pub struct SessionRecoveredView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `source_session_id` + pub source_session_id: &'a str, + /// The last source-stream ordinal the salvage drew from. + /// + /// Field 3: `source_boundary` + pub source_boundary: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Digest of the source cut, over the source's stored bytes. Binds this + /// session to exactly what was read, so a later salvage of the same source can + /// be told apart from a retry of this one. + /// + /// Field 4: `source_digest` + pub source_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// The salvage operation that produced this session, so the record holding the + /// enumerated omissions can be found from the session alone. + /// + /// Field 5: `salvage_key` + pub salvage_key: &'a str, + /// Field 6: `completeness` + pub completeness: ::buffa::EnumValue, + /// How many source items could not be carried. The enumeration lives in the + /// salvage record; the count lives here because a fold of this stream must be + /// able to conclude the session is incomplete without an operator-side lookup + /// that may not be available. + /// + /// Field 7: `omitted_count` + pub omitted_count: u32, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SessionRecoveredView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `source_session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `source_boundary` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_boundary(&self) -> bool { + self.source_boundary.is_set() + } + /**Whether required field `source_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source_digest(&self) -> bool { + self.source_digest.is_set() + } + /**Whether required field `salvage_key` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_salvage_key(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `completeness` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_completeness(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `omitted_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_omitted_count(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SessionRecoveredView<'a> { + type Owned = super::super::SessionRecovered; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source_session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_boundary.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_boundary = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.source_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.source_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.salvage_key = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 8u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.omitted_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SessionRecovered { + session_id: self.session_id.to_string(), + source_session_id: self.source_session_id.to_string(), + source_boundary: match self.source_boundary.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + source_digest: match self.source_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + salvage_key: self.salvage_key.to_string(), + completeness: self.completeness, + omitted_count: self.omitted_count, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SessionRecoveredView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(6u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(7u32, self.omitted_count, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SessionRecoveredView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("sourceSessionId", self.source_session_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.source_boundary.as_option() { + __map.serialize_entry("sourceBoundary", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.source_digest.as_option() { + __map.serialize_entry("sourceDigest", __v)?; + } + } + { + __map.serialize_entry("salvageKey", self.salvage_key)?; + } + { + __map.serialize_entry("completeness", &self.completeness)?; + } + { + __map + .serialize_entry( + "omittedCount", + &::buffa::json_helpers::ProtoJson(&self.omitted_count), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SessionRecoveredView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "SessionRecovered"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.SessionRecovered"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SessionRecovered"; +} +::buffa::impl_default_view_instance!(SessionRecoveredView); +::buffa::impl_view_reborrow!(SessionRecoveredView); +/** Self-contained, `'static` owned view of a `SessionRecovered` message. + + Wraps [`::buffa::OwnedView`]`<`[`SessionRecoveredView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SessionRecoveredView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SessionRecoveredOwnedView(::buffa::OwnedView>); +impl SessionRecoveredOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionRecoveredOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionRecoveredOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SessionRecovered, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SessionRecoveredOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SessionRecoveredView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SessionRecoveredView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SessionRecovered { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `source_session_id` + #[must_use] + pub fn source_session_id(&self) -> &'_ str { + self.0.reborrow().source_session_id + } + /// The last source-stream ordinal the salvage drew from. + /// + /// Field 3: `source_boundary` + #[must_use] + pub fn source_boundary( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().source_boundary + } + /// Digest of the source cut, over the source's stored bytes. Binds this + /// session to exactly what was read, so a later salvage of the same source can + /// be told apart from a retry of this one. + /// + /// Field 4: `source_digest` + #[must_use] + pub fn source_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().source_digest + } + /// The salvage operation that produced this session, so the record holding the + /// enumerated omissions can be found from the session alone. + /// + /// Field 5: `salvage_key` + #[must_use] + pub fn salvage_key(&self) -> &'_ str { + self.0.reborrow().salvage_key + } + /// Field 6: `completeness` + #[must_use] + pub fn completeness( + &self, + ) -> ::buffa::EnumValue { + self.0.reborrow().completeness + } + /// How many source items could not be carried. The enumeration lives in the + /// salvage record; the count lives here because a fold of this stream must be + /// able to conclude the session is incomplete without an operator-side lookup + /// that may not be available. + /// + /// Field 7: `omitted_count` + #[must_use] + pub fn omitted_count(&self) -> u32 { + self.0.reborrow().omitted_count + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SessionRecoveredOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SessionRecoveredOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SessionRecoveredOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SessionRecoveredOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SessionRecovered { + type View<'a> = SessionRecoveredView<'a>; + type ViewHandle = SessionRecoveredOwnedView; +} +impl ::serde::Serialize for SessionRecoveredOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.rs new file mode 100644 index 0000000000..fe7512a795 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.session_recovered.rs @@ -0,0 +1,439 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/session_recovered.proto + +/// RecoveryCompleteness is how much of the source this session carries. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum RecoveryCompleteness { + RECOVERY_COMPLETENESS_UNSPECIFIED = 0i32, + /// Every source event decoded and every referenced artifact verified. + RECOVERY_COMPLETENESS_COMPLETE = 1i32, + /// Items are missing. A reader must not present this session as the original. + RECOVERY_COMPLETENESS_PARTIAL = 2i32, +} +impl RecoveryCompleteness { + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RECOVERY_COMPLETENESS_UNSPECIFIED; + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_COMPLETE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Complete: Self = Self::RECOVERY_COMPLETENESS_COMPLETE; + ///Idiomatic alias for [`Self::RECOVERY_COMPLETENESS_PARTIAL`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Partial: Self = Self::RECOVERY_COMPLETENESS_PARTIAL; +} +impl ::core::default::Default for RecoveryCompleteness { + fn default() -> Self { + Self::RECOVERY_COMPLETENESS_UNSPECIFIED + } +} +impl ::serde::Serialize for RecoveryCompleteness { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for RecoveryCompleteness { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = RecoveryCompleteness; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(RecoveryCompleteness) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for RecoveryCompleteness { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for RecoveryCompleteness { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_COMPLETE), + 2i32 => ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_PARTIAL), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RECOVERY_COMPLETENESS_UNSPECIFIED => { + "RECOVERY_COMPLETENESS_UNSPECIFIED" + } + Self::RECOVERY_COMPLETENESS_COMPLETE => "RECOVERY_COMPLETENESS_COMPLETE", + Self::RECOVERY_COMPLETENESS_PARTIAL => "RECOVERY_COMPLETENESS_PARTIAL", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RECOVERY_COMPLETENESS_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_UNSPECIFIED) + } + "RECOVERY_COMPLETENESS_COMPLETE" => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_COMPLETE) + } + "RECOVERY_COMPLETENESS_PARTIAL" => { + ::core::option::Option::Some(Self::RECOVERY_COMPLETENESS_PARTIAL) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RECOVERY_COMPLETENESS_UNSPECIFIED, + Self::RECOVERY_COMPLETENESS_COMPLETE, + Self::RECOVERY_COMPLETENESS_PARTIAL, + ] + } +} +/// SessionRecovered is the second event in the atomic +/// \[SessionStarted, SessionRecovered\] creation batch appended to a salvaged +/// session's subject under the NoStream precondition, making salvage creation +/// atomic and exactly-once (ADR#0035 facet 2). +/// +/// It exists as an event rather than only as a maintenance record because a +/// reader folding this stream alone must be able to tell that this session is a +/// copy of a damaged one. A projection is rebuilt from the stream, so provenance +/// that lived only in an operator-side journal would be lost on the next rebuild +/// and the session would then read as an ordinary session with a short history. +/// +/// This is not SessionForked. A fork inherits its source by reference within +/// context_prefix_boundary and depends on the source staying readable; a +/// recovery copies, because the source's readability is the thing that failed. +/// The copied events are this session's own events at this session's own +/// ordinals: source ordinals do not carry over, and source_boundary is +/// provenance, not an index into this stream. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SessionRecovered { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `source_session_id` + #[serde( + rename = "sourceSessionId", + alias = "source_session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub source_session_id: ::buffa::alloc::string::String, + /// The last source-stream ordinal the salvage drew from. + /// + /// Field 3: `source_boundary` + #[serde(rename = "sourceBoundary", alias = "source_boundary")] + pub source_boundary: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Digest of the source cut, over the source's stored bytes. Binds this + /// session to exactly what was read, so a later salvage of the same source can + /// be told apart from a retry of this one. + /// + /// Field 4: `source_digest` + #[serde(rename = "sourceDigest", alias = "source_digest")] + pub source_digest: ::buffa::MessageField>, + /// The salvage operation that produced this session, so the record holding the + /// enumerated omissions can be found from the session alone. + /// + /// Field 5: `salvage_key` + #[serde( + rename = "salvageKey", + alias = "salvage_key", + with = "::buffa::json_helpers::proto_string" + )] + pub salvage_key: ::buffa::alloc::string::String, + /// Field 6: `completeness` + #[serde(rename = "completeness", with = "::buffa::json_helpers::proto_enum")] + pub completeness: ::buffa::EnumValue, + /// How many source items could not be carried. The enumeration lives in the + /// salvage record; the count lives here because a fold of this stream must be + /// able to conclude the session is incomplete without an operator-side lookup + /// that may not be available. + /// + /// Field 7: `omitted_count` + #[serde( + rename = "omittedCount", + alias = "omitted_count", + with = "::buffa::json_helpers::uint32" + )] + pub omitted_count: u32, +} +impl ::core::fmt::Debug for SessionRecovered { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SessionRecovered") + .field("session_id", &self.session_id) + .field("source_session_id", &self.source_session_id) + .field("source_boundary", &self.source_boundary) + .field("source_digest", &self.source_digest) + .field("salvage_key", &self.salvage_key) + .field("completeness", &self.completeness) + .field("omitted_count", &self.omitted_count) + .finish() + } +} +impl SessionRecovered { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SessionRecovered"; +} +::buffa::impl_default_instance!(SessionRecovered); +impl ::buffa::MessageName for SessionRecovered { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "SessionRecovered"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.SessionRecovered"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.SessionRecovered"; +} +impl ::buffa::Message for SessionRecovered { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.source_session_id) as u64; + if self.source_boundary.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_boundary.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.source_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.source_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.salvage_key) as u64; + { + let val = self.completeness.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.omitted_count) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.source_session_id, buf); + if self.source_boundary.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_boundary.write_to(__cache, buf); + } + if self.source_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.source_digest.write_to(__cache, buf); + } + ::buffa::types::put_string_field(5u32, &self.salvage_key, buf); + ::buffa::types::put_int32_field(6u32, self.completeness.to_i32(), buf); + ::buffa::types::put_uint32_field(7u32, self.omitted_count, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source_session_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_boundary.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.source_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.salvage_key, buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.completeness = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.omitted_count = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.source_session_id.clear(); + self.source_boundary = ::buffa::MessageField::none(); + self.source_digest = ::buffa::MessageField::none(); + self.salvage_key.clear(); + self.completeness = ::buffa::EnumValue::from(0); + self.omitted_count = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for SessionRecovered { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SESSION_RECOVERED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.SessionRecovered", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.__view.rs new file mode 100644 index 0000000000..3737a580d9 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.__view.rs @@ -0,0 +1,423 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_assistant_message.proto + +/// StartAssistantMessage opens an assistant turn, recording +/// \[AssistantMessageStarted\]. Streamed token deltas are delivered out of band +/// and never appended per token. +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct StartAssistantMessageView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `message_id` + pub message_id: &'a str, + /// Carried so a replay reproduces the request that was made, not the + /// request today's defaults would produce. + /// + /// Field 3: `model` + pub model: &'a str, + /// Field 4: `turn_id` + pub turn_id: &'a str, + /// Unset when every setting was left at the provider default. + /// + /// Field 5: `settings` + pub settings: ::buffa::MessageFieldView< + super::super::__buffa::view::ModelSettingsView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StartAssistantMessageView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `message_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_message_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `model` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_model(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StartAssistantMessageView<'a> { + type Owned = super::super::StartAssistantMessage; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.message_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.model = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.settings.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.settings = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::StartAssistantMessage, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::StartAssistantMessage, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StartAssistantMessage { + session_id: self.session_id.to_string(), + message_id: self.message_id.to_string(), + model: self.model.to_string(), + turn_id: self.turn_id.to_string(), + settings: match self.settings.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ModelSettings, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StartAssistantMessageView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.model) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.settings.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settings.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.message_id, buf); + ::buffa::types::put_string_field(3u32, &self.model, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + if self.settings.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settings.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StartAssistantMessageView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("messageId", self.message_id)?; + } + { + __map.serialize_entry("model", self.model)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.settings.as_option() { + __map.serialize_entry("settings", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StartAssistantMessageView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartAssistantMessage"; +} +::buffa::impl_default_view_instance!(StartAssistantMessageView); +::buffa::impl_view_reborrow!(StartAssistantMessageView); +/** Self-contained, `'static` owned view of a `StartAssistantMessage` message. + + Wraps [`::buffa::OwnedView`]`<`[`StartAssistantMessageView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StartAssistantMessageView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StartAssistantMessageOwnedView( + ::buffa::OwnedView>, +); +impl StartAssistantMessageOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartAssistantMessageOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartAssistantMessageOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StartAssistantMessage, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartAssistantMessageOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StartAssistantMessageView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StartAssistantMessageView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StartAssistantMessage { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `message_id` + #[must_use] + pub fn message_id(&self) -> &'_ str { + self.0.reborrow().message_id + } + /// Carried so a replay reproduces the request that was made, not the + /// request today's defaults would produce. + /// + /// Field 3: `model` + #[must_use] + pub fn model(&self) -> &'_ str { + self.0.reborrow().model + } + /// Field 4: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } + /// Unset when every setting was left at the provider default. + /// + /// Field 5: `settings` + #[must_use] + pub fn settings( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().settings + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StartAssistantMessageOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StartAssistantMessageOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StartAssistantMessageOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StartAssistantMessageOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StartAssistantMessage { + type View<'a> = StartAssistantMessageView<'a>; + type ViewHandle = StartAssistantMessageOwnedView; +} +impl ::serde::Serialize for StartAssistantMessageOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.rs new file mode 100644 index 0000000000..ec047e9179 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_assistant_message.rs @@ -0,0 +1,204 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_assistant_message.proto + +/// StartAssistantMessage opens an assistant turn, recording +/// \[AssistantMessageStarted\]. Streamed token deltas are delivered out of band +/// and never appended per token. +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StartAssistantMessage { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `message_id` + #[serde( + rename = "messageId", + alias = "message_id", + with = "::buffa::json_helpers::proto_string" + )] + pub message_id: ::buffa::alloc::string::String, + /// Carried so a replay reproduces the request that was made, not the + /// request today's defaults would produce. + /// + /// Field 3: `model` + #[serde(rename = "model", with = "::buffa::json_helpers::proto_string")] + pub model: ::buffa::alloc::string::String, + /// Field 4: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, + /// Unset when every setting was left at the provider default. + /// + /// Field 5: `settings` + #[serde( + rename = "settings", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub settings: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for StartAssistantMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StartAssistantMessage") + .field("session_id", &self.session_id) + .field("message_id", &self.message_id) + .field("model", &self.model) + .field("turn_id", &self.turn_id) + .field("settings", &self.settings) + .finish() + } +} +impl StartAssistantMessage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartAssistantMessage"; +} +::buffa::impl_default_instance!(StartAssistantMessage); +impl ::buffa::MessageName for StartAssistantMessage { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartAssistantMessage"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartAssistantMessage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartAssistantMessage"; +} +impl ::buffa::Message for StartAssistantMessage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.message_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.model) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + if self.settings.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.settings.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.message_id, buf); + ::buffa::types::put_string_field(3u32, &self.model, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + if self.settings.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.settings.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.message_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.model, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.settings.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.message_id.clear(); + self.model.clear(); + self.turn_id.clear(); + self.settings = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StartAssistantMessage { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __START_ASSISTANT_MESSAGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartAssistantMessage", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.__view.rs new file mode 100644 index 0000000000..7e176e9582 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.__view.rs @@ -0,0 +1,736 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_execution_attempt.proto + +/// StartExecutionAttempt claims the session for a runner, recording +/// \[ExecutionAttemptStarted\]. +/// +/// Write precondition At: one active attempt at a time, monotonic attempt +/// numbers, and a restored checkpoint that exactly equals the first admitted +/// evidence for its id with no later redaction or erasure reaching at or before +/// its covers_through (ADR#0035 harness recovery). +#[derive(Clone, Debug, Default)] +pub struct StartExecutionAttemptView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `execution_attempt_id` + pub execution_attempt_id: &'a str, + /// Must equal the session's stored plan digest; a mismatch means the runner + /// is about to execute a different plan than the session was started with. + /// + /// Field 3: `session_execution_plan_digest` + pub session_execution_plan_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 4: `attempt_number` + pub attempt_number: u64, + /// Field 5: `previous_attempt_id` + pub previous_attempt_id: ::core::option::Option<&'a str>, + /// Unset when the attempt starts from scratch rather than restoring. + /// + /// Field 6: `restored_checkpoint` + pub restored_checkpoint: ::buffa::MessageFieldView< + super::super::__buffa::view::CheckpointView<'a>, + >, + /// Field 7: `host_artifact_ref` + pub host_artifact_ref: &'a str, + /// Field 8: `host_artifact_digest` + pub host_artifact_digest: ::buffa::MessageFieldView< + super::super::__buffa::view::DigestView<'a>, + >, + /// Field 9: `authenticated_remote_subject` + pub authenticated_remote_subject: ::core::option::Option<&'a str>, + /// Field 10: `isolation_placement` + pub isolation_placement: ::core::option::Option<&'a str>, + /// Supplied by the caller: deciding is deterministic and reads no clock. + /// + /// Field 11: `started_at` + pub started_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StartExecutionAttemptView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `execution_attempt_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_execution_attempt_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `session_execution_plan_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_execution_plan_digest(&self) -> bool { + self.session_execution_plan_digest.is_set() + } + /**Whether required field `attempt_number` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_attempt_number(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `host_artifact_ref` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_host_artifact_ref(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `host_artifact_digest` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_host_artifact_digest(&self) -> bool { + self.host_artifact_digest.is_set() + } + /**Whether required field `started_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_started_at(&self) -> bool { + self.started_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for StartExecutionAttemptView<'a> { + type Owned = super::super::StartExecutionAttempt; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.execution_attempt_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.session_execution_plan_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.session_execution_plan_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.attempt_number = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.previous_attempt_id = Some(::buffa::types::borrow_str(&mut cur)?); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.restored_checkpoint.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.restored_checkpoint = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.host_artifact_ref = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.host_artifact_digest.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.host_artifact_digest = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.authenticated_remote_subject = Some( + ::buffa::types::borrow_str(&mut cur)?, + ); + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.isolation_placement = Some(::buffa::types::borrow_str(&mut cur)?); + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.started_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.started_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::StartExecutionAttempt, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::StartExecutionAttempt, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StartExecutionAttempt { + session_id: self.session_id.to_string(), + execution_attempt_id: self.execution_attempt_id.to_string(), + session_execution_plan_digest: match self + .session_execution_plan_digest + .as_option() + { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + attempt_number: self.attempt_number, + previous_attempt_id: self.previous_attempt_id.map(|s| s.to_string()), + restored_checkpoint: match self.restored_checkpoint.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Checkpoint, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + host_artifact_ref: self.host_artifact_ref.to_string(), + host_artifact_digest: match self.host_artifact_digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::Digest, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + authenticated_remote_subject: self + .authenticated_remote_subject + .map(|s| s.to_string()), + isolation_placement: self.isolation_placement.map(|s| s.to_string()), + started_at: match self.started_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StartExecutionAttemptView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + if self.session_execution_plan_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session_execution_plan_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.attempt_number) as u64; + if let Some(ref v) = self.previous_attempt_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.restored_checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.restored_checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.host_artifact_ref) as u64; + if self.host_artifact_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.host_artifact_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.authenticated_remote_subject { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.isolation_placement { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + if self.session_execution_plan_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session_execution_plan_digest.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(4u32, self.attempt_number, buf); + if let Some(ref v) = self.previous_attempt_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + if self.restored_checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.restored_checkpoint.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.host_artifact_ref, buf); + if self.host_artifact_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.host_artifact_digest.write_to(__cache, buf); + } + if let Some(ref v) = self.authenticated_remote_subject { + ::buffa::types::put_string_field(9u32, v, buf); + } + if let Some(ref v) = self.isolation_placement { + ::buffa::types::put_string_field(10u32, v, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StartExecutionAttemptView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("executionAttemptId", self.execution_attempt_id)?; + } + { + if let ::core::option::Option::Some(__v) = self + .session_execution_plan_digest + .as_option() + { + __map.serialize_entry("sessionExecutionPlanDigest", __v)?; + } + } + { + __map + .serialize_entry( + "attemptNumber", + &::buffa::json_helpers::ProtoJson(&self.attempt_number), + )?; + } + if let ::core::option::Option::Some(__v) = self.previous_attempt_id { + __map.serialize_entry("previousAttemptId", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self + .restored_checkpoint + .as_option() + { + __map.serialize_entry("restoredCheckpoint", __v)?; + } + } + { + __map.serialize_entry("hostArtifactRef", self.host_artifact_ref)?; + } + { + if let ::core::option::Option::Some(__v) = self + .host_artifact_digest + .as_option() + { + __map.serialize_entry("hostArtifactDigest", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.authenticated_remote_subject { + __map.serialize_entry("authenticatedRemoteSubject", __v)?; + } + if let ::core::option::Option::Some(__v) = self.isolation_placement { + __map.serialize_entry("isolationPlacement", __v)?; + } + { + if let ::core::option::Option::Some(__v) = self.started_at.as_option() { + __map.serialize_entry("startedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StartExecutionAttemptView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartExecutionAttempt"; +} +::buffa::impl_default_view_instance!(StartExecutionAttemptView); +::buffa::impl_view_reborrow!(StartExecutionAttemptView); +/** Self-contained, `'static` owned view of a `StartExecutionAttempt` message. + + Wraps [`::buffa::OwnedView`]`<`[`StartExecutionAttemptView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StartExecutionAttemptView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StartExecutionAttemptOwnedView( + ::buffa::OwnedView>, +); +impl StartExecutionAttemptOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartExecutionAttemptOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartExecutionAttemptOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StartExecutionAttempt, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartExecutionAttemptOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StartExecutionAttemptView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StartExecutionAttemptView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StartExecutionAttempt { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `execution_attempt_id` + #[must_use] + pub fn execution_attempt_id(&self) -> &'_ str { + self.0.reborrow().execution_attempt_id + } + /// Must equal the session's stored plan digest; a mismatch means the runner + /// is about to execute a different plan than the session was started with. + /// + /// Field 3: `session_execution_plan_digest` + #[must_use] + pub fn session_execution_plan_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().session_execution_plan_digest + } + /// Field 4: `attempt_number` + #[must_use] + pub fn attempt_number(&self) -> u64 { + self.0.reborrow().attempt_number + } + /// Field 5: `previous_attempt_id` + #[must_use] + pub fn previous_attempt_id(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().previous_attempt_id + } + /// Unset when the attempt starts from scratch rather than restoring. + /// + /// Field 6: `restored_checkpoint` + #[must_use] + pub fn restored_checkpoint( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().restored_checkpoint + } + /// Field 7: `host_artifact_ref` + #[must_use] + pub fn host_artifact_ref(&self) -> &'_ str { + self.0.reborrow().host_artifact_ref + } + /// Field 8: `host_artifact_digest` + #[must_use] + pub fn host_artifact_digest( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().host_artifact_digest + } + /// Field 9: `authenticated_remote_subject` + #[must_use] + pub fn authenticated_remote_subject(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().authenticated_remote_subject + } + /// Field 10: `isolation_placement` + #[must_use] + pub fn isolation_placement(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().isolation_placement + } + /// Supplied by the caller: deciding is deterministic and reads no clock. + /// + /// Field 11: `started_at` + #[must_use] + pub fn started_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().started_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StartExecutionAttemptOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StartExecutionAttemptOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StartExecutionAttemptOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StartExecutionAttemptOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StartExecutionAttempt { + type View<'a> = StartExecutionAttemptView<'a>; + type ViewHandle = StartExecutionAttemptOwnedView; +} +impl ::serde::Serialize for StartExecutionAttemptOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.rs new file mode 100644 index 0000000000..3cfff3267a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_execution_attempt.rs @@ -0,0 +1,439 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_execution_attempt.proto + +/// StartExecutionAttempt claims the session for a runner, recording +/// \[ExecutionAttemptStarted\]. +/// +/// Write precondition At: one active attempt at a time, monotonic attempt +/// numbers, and a restored checkpoint that exactly equals the first admitted +/// evidence for its id with no later redaction or erasure reaching at or before +/// its covers_through (ADR#0035 harness recovery). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StartExecutionAttempt { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `execution_attempt_id` + #[serde( + rename = "executionAttemptId", + alias = "execution_attempt_id", + with = "::buffa::json_helpers::proto_string" + )] + pub execution_attempt_id: ::buffa::alloc::string::String, + /// Must equal the session's stored plan digest; a mismatch means the runner + /// is about to execute a different plan than the session was started with. + /// + /// Field 3: `session_execution_plan_digest` + #[serde( + rename = "sessionExecutionPlanDigest", + alias = "session_execution_plan_digest" + )] + pub session_execution_plan_digest: ::buffa::MessageField< + Digest, + ::buffa::Inline, + >, + /// Field 4: `attempt_number` + #[serde( + rename = "attemptNumber", + alias = "attempt_number", + with = "::buffa::json_helpers::uint64" + )] + pub attempt_number: u64, + /// Field 5: `previous_attempt_id` + #[serde( + rename = "previousAttemptId", + alias = "previous_attempt_id", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub previous_attempt_id: ::core::option::Option<::buffa::alloc::string::String>, + /// Unset when the attempt starts from scratch rather than restoring. + /// + /// Field 6: `restored_checkpoint` + #[serde( + rename = "restoredCheckpoint", + alias = "restored_checkpoint", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub restored_checkpoint: ::buffa::MessageField< + Checkpoint, + ::buffa::Inline, + >, + /// Field 7: `host_artifact_ref` + #[serde( + rename = "hostArtifactRef", + alias = "host_artifact_ref", + with = "::buffa::json_helpers::proto_string" + )] + pub host_artifact_ref: ::buffa::alloc::string::String, + /// Field 8: `host_artifact_digest` + #[serde(rename = "hostArtifactDigest", alias = "host_artifact_digest")] + pub host_artifact_digest: ::buffa::MessageField>, + /// Field 9: `authenticated_remote_subject` + #[serde( + rename = "authenticatedRemoteSubject", + alias = "authenticated_remote_subject", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub authenticated_remote_subject: ::core::option::Option< + ::buffa::alloc::string::String, + >, + /// Field 10: `isolation_placement` + #[serde( + rename = "isolationPlacement", + alias = "isolation_placement", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub isolation_placement: ::core::option::Option<::buffa::alloc::string::String>, + /// Supplied by the caller: deciding is deterministic and reads no clock. + /// + /// Field 11: `started_at` + #[serde(rename = "startedAt", alias = "started_at")] + pub started_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for StartExecutionAttempt { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StartExecutionAttempt") + .field("session_id", &self.session_id) + .field("execution_attempt_id", &self.execution_attempt_id) + .field("session_execution_plan_digest", &self.session_execution_plan_digest) + .field("attempt_number", &self.attempt_number) + .field("previous_attempt_id", &self.previous_attempt_id) + .field("restored_checkpoint", &self.restored_checkpoint) + .field("host_artifact_ref", &self.host_artifact_ref) + .field("host_artifact_digest", &self.host_artifact_digest) + .field("authenticated_remote_subject", &self.authenticated_remote_subject) + .field("isolation_placement", &self.isolation_placement) + .field("started_at", &self.started_at) + .finish() + } +} +impl StartExecutionAttempt { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartExecutionAttempt"; +} +impl StartExecutionAttempt { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::previous_attempt_id`] to `Some(value)`, consuming and returning `self`. + pub fn with_previous_attempt_id( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.previous_attempt_id = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::authenticated_remote_subject`] to `Some(value)`, consuming and returning `self`. + pub fn with_authenticated_remote_subject( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.authenticated_remote_subject = Some(value.into()); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::isolation_placement`] to `Some(value)`, consuming and returning `self`. + pub fn with_isolation_placement( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.isolation_placement = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(StartExecutionAttempt); +impl ::buffa::MessageName for StartExecutionAttempt { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartExecutionAttempt"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartExecutionAttempt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartExecutionAttempt"; +} +impl ::buffa::Message for StartExecutionAttempt { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.execution_attempt_id) as u64; + if self.session_execution_plan_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.session_execution_plan_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.attempt_number) as u64; + if let Some(ref v) = self.previous_attempt_id { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.restored_checkpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.restored_checkpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + ::buffa::types::string_encoded_len(&self.host_artifact_ref) as u64; + if self.host_artifact_digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.host_artifact_digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.authenticated_remote_subject { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if let Some(ref v) = self.isolation_placement { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + if self.started_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.started_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.execution_attempt_id, buf); + if self.session_execution_plan_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.session_execution_plan_digest.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(4u32, self.attempt_number, buf); + if let Some(ref v) = self.previous_attempt_id { + ::buffa::types::put_string_field(5u32, v, buf); + } + if self.restored_checkpoint.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.restored_checkpoint.write_to(__cache, buf); + } + ::buffa::types::put_string_field(7u32, &self.host_artifact_ref, buf); + if self.host_artifact_digest.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.host_artifact_digest.write_to(__cache, buf); + } + if let Some(ref v) = self.authenticated_remote_subject { + ::buffa::types::put_string_field(9u32, v, buf); + } + if let Some(ref v) = self.isolation_placement { + ::buffa::types::put_string_field(10u32, v, buf); + } + if self.started_at.is_set() { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + self.started_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.execution_attempt_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.session_execution_plan_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.attempt_number = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .previous_attempt_id + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.restored_checkpoint.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.host_artifact_ref, buf)?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.host_artifact_digest.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .authenticated_remote_subject + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self + .isolation_placement + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.started_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.execution_attempt_id.clear(); + self.session_execution_plan_digest = ::buffa::MessageField::none(); + self.attempt_number = 0u64; + self.previous_attempt_id = ::core::option::Option::None; + self.restored_checkpoint = ::buffa::MessageField::none(); + self.host_artifact_ref.clear(); + self.host_artifact_digest = ::buffa::MessageField::none(); + self.authenticated_remote_subject = ::core::option::Option::None; + self.isolation_placement = ::core::option::Option::None; + self.started_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StartExecutionAttempt { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __START_EXECUTION_ATTEMPT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartExecutionAttempt", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.__view.rs new file mode 100644 index 0000000000..0cb4ec894f --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.__view.rs @@ -0,0 +1,343 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_tool_call.proto + +/// StartToolCall records that execution began, recording \[ToolCallStarted\]. +/// +/// Write precondition Any. This is the fact a crash strands: a started call with +/// no terminal outcome is exactly what replay must expose so reconciliation can +/// finish or reject it. A start whose tool_call_id matches no request folds as +/// unjoined and is flagged, never refused (ADR#0035 orphan happened-fact rule). +#[derive(Clone, Debug, Default)] +pub struct StartToolCallView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// Field 2: `tool_call_id` + pub tool_call_id: &'a str, + /// Field 3: `tool_execution_id` + pub tool_execution_id: &'a str, + /// Field 4: `turn_id` + pub turn_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> StartToolCallView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `tool_call_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_call_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `tool_execution_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_tool_execution_id(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `turn_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_turn_id(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for StartToolCallView<'a> { + type Owned = super::super::StartToolCall; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_call_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.tool_execution_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.turn_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::StartToolCall { + session_id: self.session_id.to_string(), + tool_call_id: self.tool_call_id.to_string(), + tool_execution_id: self.tool_execution_id.to_string(), + turn_id: self.turn_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for StartToolCallView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for StartToolCallView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map.serialize_entry("toolCallId", self.tool_call_id)?; + } + { + __map.serialize_entry("toolExecutionId", self.tool_execution_id)?; + } + { + __map.serialize_entry("turnId", self.turn_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for StartToolCallView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartToolCall"; +} +::buffa::impl_default_view_instance!(StartToolCallView); +::buffa::impl_view_reborrow!(StartToolCallView); +/** Self-contained, `'static` owned view of a `StartToolCall` message. + + Wraps [`::buffa::OwnedView`]`<`[`StartToolCallView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StartToolCallView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct StartToolCallOwnedView(::buffa::OwnedView>); +impl StartToolCallOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartToolCallOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartToolCallOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::StartToolCall, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + StartToolCallOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`StartToolCallView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &StartToolCallView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::StartToolCall { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// Field 2: `tool_call_id` + #[must_use] + pub fn tool_call_id(&self) -> &'_ str { + self.0.reborrow().tool_call_id + } + /// Field 3: `tool_execution_id` + #[must_use] + pub fn tool_execution_id(&self) -> &'_ str { + self.0.reborrow().tool_execution_id + } + /// Field 4: `turn_id` + #[must_use] + pub fn turn_id(&self) -> &'_ str { + self.0.reborrow().turn_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for StartToolCallOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + StartToolCallOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: StartToolCallOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for StartToolCallOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::StartToolCall { + type View<'a> = StartToolCallView<'a>; + type ViewHandle = StartToolCallOwnedView; +} +impl ::serde::Serialize for StartToolCallOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.rs new file mode 100644 index 0000000000..01435e0838 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.start_tool_call.rs @@ -0,0 +1,170 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/start_tool_call.proto + +/// StartToolCall records that execution began, recording \[ToolCallStarted\]. +/// +/// Write precondition Any. This is the fact a crash strands: a started call with +/// no terminal outcome is exactly what replay must expose so reconciliation can +/// finish or reject it. A start whose tool_call_id matches no request folds as +/// unjoined and is flagged, never refused (ADR#0035 orphan happened-fact rule). +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StartToolCall { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// Field 2: `tool_call_id` + #[serde( + rename = "toolCallId", + alias = "tool_call_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_call_id: ::buffa::alloc::string::String, + /// Field 3: `tool_execution_id` + #[serde( + rename = "toolExecutionId", + alias = "tool_execution_id", + with = "::buffa::json_helpers::proto_string" + )] + pub tool_execution_id: ::buffa::alloc::string::String, + /// Field 4: `turn_id` + #[serde( + rename = "turnId", + alias = "turn_id", + with = "::buffa::json_helpers::proto_string" + )] + pub turn_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for StartToolCall { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StartToolCall") + .field("session_id", &self.session_id) + .field("tool_call_id", &self.tool_call_id) + .field("tool_execution_id", &self.tool_execution_id) + .field("turn_id", &self.turn_id) + .finish() + } +} +impl StartToolCall { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartToolCall"; +} +::buffa::impl_default_instance!(StartToolCall); +impl ::buffa::MessageName for StartToolCall { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "StartToolCall"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.StartToolCall"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartToolCall"; +} +impl ::buffa::Message for StartToolCall { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.tool_call_id) as u64; + size + += 1u64 + ::buffa::types::string_encoded_len(&self.tool_execution_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.turn_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_string_field(2u32, &self.tool_call_id, buf); + ::buffa::types::put_string_field(3u32, &self.tool_execution_id, buf); + ::buffa::types::put_string_field(4u32, &self.turn_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_call_id, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.tool_execution_id, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.turn_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.tool_call_id.clear(); + self.tool_execution_id.clear(); + self.turn_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for StartToolCall { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __START_TOOL_CALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.StartToolCall", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.__view.rs new file mode 100644 index 0000000000..5038421fda --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.__view.rs @@ -0,0 +1,337 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/target_outcome.proto + +/// TargetOutcome records one target a multi-resource tool call failed to apply. +/// +/// A batch edit over ten files that succeeds for eight and fails for two is not a +/// failure. Eight files really changed, and those changes exist independently of +/// how the call is labelled: they are FileChanged facts on the log and no result +/// status can retract them. Such a call is therefore a ToolCallCompleted with +/// result status TOOL_CALL_RESULT_STATUS_APPLICATION_ERROR, never a +/// ToolCallFailed, which means nothing was applied at all. +/// +/// Only failures are recorded here. The successes are already durable as +/// FileChanged, and recording them a second time would create two facts for one +/// change that can disagree after a rewind or a redaction masks one of them. What +/// no other event can express is the negative: that a target was named, attempted, +/// and did not happen. Without it a reader sees eight changes for a ten-file +/// request and has to infer the gap by comparing against tool arguments, which is +/// exactly the inference a typed record exists to make unnecessary. +#[derive(Clone, Debug, Default)] +pub struct TargetOutcomeView<'a> { + /// The target as addressed by the call, in the same URI form as + /// WorkspaceRef.uri. A URI rather than a workspace-relative path because a + /// multi-resource tool's targets are not always files, and a failure against an + /// MCP resource or a remote endpoint has no path to record. + /// + /// Field 1: `target_uri` + pub target_uri: &'a str, + /// Field 2: `reason` + pub reason: ::buffa::EnumValue, + /// Detail from the tool, for humans. Never parsed. + /// + /// Field 3: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> TargetOutcomeView<'a> { + /**Whether required field `target_uri` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_target_uri(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for TargetOutcomeView<'a> { + type Owned = super::super::TargetOutcome; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.target_uri = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::TargetOutcome { + target_uri: self.target_uri.to_string(), + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for TargetOutcomeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.target_uri) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.target_uri, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for TargetOutcomeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("targetUri", self.target_uri)?; + } + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for TargetOutcomeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "TargetOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.TargetOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.TargetOutcome"; +} +::buffa::impl_default_view_instance!(TargetOutcomeView); +::buffa::impl_view_reborrow!(TargetOutcomeView); +/** Self-contained, `'static` owned view of a `TargetOutcome` message. + + Wraps [`::buffa::OwnedView`]`<`[`TargetOutcomeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`TargetOutcomeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct TargetOutcomeOwnedView(::buffa::OwnedView>); +impl TargetOutcomeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + TargetOutcomeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + TargetOutcomeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::TargetOutcome, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + TargetOutcomeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`TargetOutcomeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &TargetOutcomeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::TargetOutcome { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The target as addressed by the call, in the same URI form as + /// WorkspaceRef.uri. A URI rather than a workspace-relative path because a + /// multi-resource tool's targets are not always files, and a failure against an + /// MCP resource or a remote endpoint has no path to record. + /// + /// Field 1: `target_uri` + #[must_use] + pub fn target_uri(&self) -> &'_ str { + self.0.reborrow().target_uri + } + /// Field 2: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Detail from the tool, for humans. Never parsed. + /// + /// Field 3: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for TargetOutcomeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + TargetOutcomeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: TargetOutcomeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for TargetOutcomeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::TargetOutcome { + type View<'a> = TargetOutcomeView<'a>; + type ViewHandle = TargetOutcomeOwnedView; +} +impl ::serde::Serialize for TargetOutcomeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.rs new file mode 100644 index 0000000000..3787d0faa1 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.target_outcome.rs @@ -0,0 +1,449 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/target_outcome.proto + +/// TargetFailureReason is why one target of a multi-target call did not apply. +/// +/// Typed because the reasons carry different meanings for whether retrying is +/// sound. A permission fault is durable and a retry repeats it; a stale +/// precondition means the resource moved under the agent and a retry against +/// fresh content may well succeed; a not-attempted target failed for no reason of +/// its own at all. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum TargetFailureReason { + TARGET_FAILURE_REASON_UNSPECIFIED = 0i32, + /// The target did not exist. + TARGET_FAILURE_REASON_NOT_FOUND = 1i32, + /// Access was refused by the underlying system. + TARGET_FAILURE_REASON_PERMISSION_DENIED = 2i32, + /// The target's content no longer matched what the change was decided against, + /// which is the ResourceObservation digest that justified the write. + TARGET_FAILURE_REASON_PRECONDITION_FAILED = 3i32, + /// The requested edit did not match anything in the target. + TARGET_FAILURE_REASON_NO_MATCH = 4i32, + /// The edit matched ambiguously and was refused rather than guessed at. + TARGET_FAILURE_REASON_AMBIGUOUS_MATCH = 5i32, + /// The target could not be interpreted in the form the tool required. + TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT = 6i32, + /// The call stopped before reaching this target. It is not a failure of the + /// target and says nothing about whether it would have succeeded; recorded so a + /// reader never concludes an unreached target was rejected. + TARGET_FAILURE_REASON_NOT_ATTEMPTED = 7i32, + /// The underlying system failed in a way the tool could not classify. + TARGET_FAILURE_REASON_IO_ERROR = 8i32, +} +impl TargetFailureReason { + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::TARGET_FAILURE_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_NOT_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotFound: Self = Self::TARGET_FAILURE_REASON_NOT_FOUND; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_PERMISSION_DENIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PermissionDenied: Self = Self::TARGET_FAILURE_REASON_PERMISSION_DENIED; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const PreconditionFailed: Self = Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_NO_MATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NoMatch: Self = Self::TARGET_FAILURE_REASON_NO_MATCH; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AmbiguousMatch: Self = Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnsupportedContent: Self = Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotAttempted: Self = Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED; + ///Idiomatic alias for [`Self::TARGET_FAILURE_REASON_IO_ERROR`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IoError: Self = Self::TARGET_FAILURE_REASON_IO_ERROR; +} +impl ::core::default::Default for TargetFailureReason { + fn default() -> Self { + Self::TARGET_FAILURE_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for TargetFailureReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for TargetFailureReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = TargetFailureReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(TargetFailureReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for TargetFailureReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for TargetFailureReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NOT_FOUND), + 2i32 => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_PERMISSION_DENIED, + ) + } + 3i32 => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED, + ) + } + 4i32 => ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NO_MATCH), + 5i32 => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH) + } + 6i32 => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT, + ) + } + 7i32 => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED) + } + 8i32 => ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_IO_ERROR), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::TARGET_FAILURE_REASON_UNSPECIFIED => { + "TARGET_FAILURE_REASON_UNSPECIFIED" + } + Self::TARGET_FAILURE_REASON_NOT_FOUND => "TARGET_FAILURE_REASON_NOT_FOUND", + Self::TARGET_FAILURE_REASON_PERMISSION_DENIED => { + "TARGET_FAILURE_REASON_PERMISSION_DENIED" + } + Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED => { + "TARGET_FAILURE_REASON_PRECONDITION_FAILED" + } + Self::TARGET_FAILURE_REASON_NO_MATCH => "TARGET_FAILURE_REASON_NO_MATCH", + Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH => { + "TARGET_FAILURE_REASON_AMBIGUOUS_MATCH" + } + Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT => { + "TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT" + } + Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED => { + "TARGET_FAILURE_REASON_NOT_ATTEMPTED" + } + Self::TARGET_FAILURE_REASON_IO_ERROR => "TARGET_FAILURE_REASON_IO_ERROR", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "TARGET_FAILURE_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_UNSPECIFIED) + } + "TARGET_FAILURE_REASON_NOT_FOUND" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NOT_FOUND) + } + "TARGET_FAILURE_REASON_PERMISSION_DENIED" => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_PERMISSION_DENIED, + ) + } + "TARGET_FAILURE_REASON_PRECONDITION_FAILED" => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED, + ) + } + "TARGET_FAILURE_REASON_NO_MATCH" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NO_MATCH) + } + "TARGET_FAILURE_REASON_AMBIGUOUS_MATCH" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH) + } + "TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT" => { + ::core::option::Option::Some( + Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT, + ) + } + "TARGET_FAILURE_REASON_NOT_ATTEMPTED" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED) + } + "TARGET_FAILURE_REASON_IO_ERROR" => { + ::core::option::Option::Some(Self::TARGET_FAILURE_REASON_IO_ERROR) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::TARGET_FAILURE_REASON_UNSPECIFIED, + Self::TARGET_FAILURE_REASON_NOT_FOUND, + Self::TARGET_FAILURE_REASON_PERMISSION_DENIED, + Self::TARGET_FAILURE_REASON_PRECONDITION_FAILED, + Self::TARGET_FAILURE_REASON_NO_MATCH, + Self::TARGET_FAILURE_REASON_AMBIGUOUS_MATCH, + Self::TARGET_FAILURE_REASON_UNSUPPORTED_CONTENT, + Self::TARGET_FAILURE_REASON_NOT_ATTEMPTED, + Self::TARGET_FAILURE_REASON_IO_ERROR, + ] + } +} +/// TargetOutcome records one target a multi-resource tool call failed to apply. +/// +/// A batch edit over ten files that succeeds for eight and fails for two is not a +/// failure. Eight files really changed, and those changes exist independently of +/// how the call is labelled: they are FileChanged facts on the log and no result +/// status can retract them. Such a call is therefore a ToolCallCompleted with +/// result status TOOL_CALL_RESULT_STATUS_APPLICATION_ERROR, never a +/// ToolCallFailed, which means nothing was applied at all. +/// +/// Only failures are recorded here. The successes are already durable as +/// FileChanged, and recording them a second time would create two facts for one +/// change that can disagree after a rewind or a redaction masks one of them. What +/// no other event can express is the negative: that a target was named, attempted, +/// and did not happen. Without it a reader sees eight changes for a ten-file +/// request and has to infer the gap by comparing against tool arguments, which is +/// exactly the inference a typed record exists to make unnecessary. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct TargetOutcome { + /// The target as addressed by the call, in the same URI form as + /// WorkspaceRef.uri. A URI rather than a workspace-relative path because a + /// multi-resource tool's targets are not always files, and a failure against an + /// MCP resource or a remote endpoint has no path to record. + /// + /// Field 1: `target_uri` + #[serde( + rename = "targetUri", + alias = "target_uri", + with = "::buffa::json_helpers::proto_string" + )] + pub target_uri: ::buffa::alloc::string::String, + /// Field 2: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Detail from the tool, for humans. Never parsed. + /// + /// Field 3: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for TargetOutcome { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TargetOutcome") + .field("target_uri", &self.target_uri) + .field("reason", &self.reason) + .field("detail", &self.detail) + .finish() + } +} +impl TargetOutcome { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.TargetOutcome"; +} +impl TargetOutcome { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(TargetOutcome); +impl ::buffa::MessageName for TargetOutcome { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "TargetOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.TargetOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.TargetOutcome"; +} +impl ::buffa::Message for TargetOutcome { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.target_uri) as u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.target_uri, buf); + ::buffa::types::put_int32_field(2u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(3u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.target_uri, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.target_uri.clear(); + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for TargetOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __TARGET_OUTCOME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.TargetOutcome", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.__view.rs index e5488b083d..42ebfa69ae 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.__view.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.__view.rs @@ -48,6 +48,58 @@ pub struct ToolCallCompletedView<'a> { 'a, super::super::__buffa::view::ResourceObservationView<'a>, >, + /// Claim-check to this command's captured stdout and stderr, for a tool that + /// executes a process and captured it; unset otherwise, including for a + /// command that ran with capture disabled. + /// + /// It sits here beside `termination` and not inside `result` for the reason + /// `termination` does (D11): captured output is the execution record, while + /// `result` is the transcript the model received. They routinely differ, since + /// what reaches the model is truncated or summarized, and folding raw output + /// into the replay shape would hand a later turn context the original turn + /// never had. + /// + /// Field 9: `output_replay` + pub output_replay: ::buffa::MessageFieldView< + super::super::__buffa::view::CommandOutputReplayRefView<'a>, + >, + /// Set when this call returned a handle to work that outlived the turn. Unset + /// is the ordinary case and means the call's result is its outcome; set means + /// the result is a handle and the outcome arrives later through the operation + /// ledger. + /// + /// Field 10: `detached` + pub detached: ::buffa::MessageFieldView< + super::super::__buffa::view::DetachedWorkView<'a>, + >, + /// Namespaces this call listed, searched, or otherwise touched, as distinct + /// from the content it read. Empty for a call that accessed no namespace. + /// + /// Field 11: `accessed` + pub accessed: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::ResourceAccessRecordView<'a>, + >, + /// Targets of a multi-resource call that did not apply. Empty when every target + /// succeeded, and empty is also correct for a single-target call, which has + /// nothing partial to report. + /// + /// Successes are deliberately absent: they are already FileChanged facts, and a + /// second record of the same change is a second thing to keep consistent + /// through rewind and redaction. + /// + /// Field 12: `failed_targets` + pub failed_targets: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::TargetOutcomeView<'a>, + >, + /// How many targets the call set out to apply, recorded so failed_targets can + /// be read as a fraction. Zero for a call with no target list, which is not the + /// same as a call that attempted zero targets and is why the count is here + /// rather than inferred from an empty list. + /// + /// Field 13: `targets_attempted` + pub targets_attempted: ::core::option::Option, #[doc(hidden)] pub __buffa_required_seen_0: u64, } @@ -216,6 +268,55 @@ impl<'a> ::buffa::MessageView<'a> for ToolCallCompletedView<'a> { } } } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.output_replay.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.output_replay = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.detached.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.detached = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.targets_attempted = Some(::buffa::types::decode_uint32(&mut cur)?); + } 8u32 => { ::buffa::encoding::check_wire_type( tag, @@ -236,6 +337,46 @@ impl<'a> ::buffa::MessageView<'a> for ToolCallCompletedView<'a> { )?, ); } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::ResourceAccessRecordView, + >(), + )?; + view.accessed + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::TargetOutcomeView, + >(), + )?; + view.failed_targets + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } _ => { ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; } @@ -292,6 +433,35 @@ impl<'a> ::buffa::MessageView<'a> for ToolCallCompletedView<'a> { .iter() .map(|v| v.to_owned_from_source(__buffa_src)) .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + output_replay: match self.output_replay.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::CommandOutputReplayRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detached: match self.detached.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::DetachedWork, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + accessed: self + .accessed + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + failed_targets: self + .failed_targets + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + targets_attempted: self.targets_attempted, ..::core::default::Default::default() }) } @@ -339,6 +509,41 @@ impl<'a> ::buffa::ViewEncode<'a> for ToolCallCompletedView<'a> { += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + if self.output_replay.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output_replay.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.detached.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.accessed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.failed_targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.targets_attempted { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } ::buffa::saturate_size(size) } #[allow(clippy::needless_borrow)] @@ -385,6 +590,41 @@ impl<'a> ::buffa::ViewEncode<'a> for ToolCallCompletedView<'a> { ); v.write_to(__cache, buf); } + if self.output_replay.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.output_replay.write_to(__cache, buf); + } + if self.detached.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached.write_to(__cache, buf); + } + for v in &self.accessed { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.failed_targets { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(v) = self.targets_attempted { + ::buffa::types::put_uint32_field(13u32, v, buf); + } } } /// Serializes this view as protobuf JSON. @@ -435,6 +675,29 @@ impl<'__a> ::serde::Serialize for ToolCallCompletedView<'__a> { if !self.observed.is_empty() { __map.serialize_entry("observed", &*self.observed)?; } + { + if let ::core::option::Option::Some(__v) = self.output_replay.as_option() { + __map.serialize_entry("outputReplay", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.detached.as_option() { + __map.serialize_entry("detached", __v)?; + } + } + if !self.accessed.is_empty() { + __map.serialize_entry("accessed", &*self.accessed)?; + } + if !self.failed_targets.is_empty() { + __map.serialize_entry("failedTargets", &*self.failed_targets)?; + } + if let ::core::option::Option::Some(__v) = self.targets_attempted { + __map + .serialize_entry( + "targetsAttempted", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } __map.end() } } @@ -601,6 +864,76 @@ impl ToolCallCompletedOwnedView { > { &self.0.reborrow().observed } + /// Claim-check to this command's captured stdout and stderr, for a tool that + /// executes a process and captured it; unset otherwise, including for a + /// command that ran with capture disabled. + /// + /// It sits here beside `termination` and not inside `result` for the reason + /// `termination` does (D11): captured output is the execution record, while + /// `result` is the transcript the model received. They routinely differ, since + /// what reaches the model is truncated or summarized, and folding raw output + /// into the replay shape would hand a later turn context the original turn + /// never had. + /// + /// Field 9: `output_replay` + #[must_use] + pub fn output_replay( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::CommandOutputReplayRefView<'_>, + > { + &self.0.reborrow().output_replay + } + /// Set when this call returned a handle to work that outlived the turn. Unset + /// is the ordinary case and means the call's result is its outcome; set means + /// the result is a handle and the outcome arrives later through the operation + /// ledger. + /// + /// Field 10: `detached` + #[must_use] + pub fn detached( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().detached + } + /// Namespaces this call listed, searched, or otherwise touched, as distinct + /// from the content it read. Empty for a call that accessed no namespace. + /// + /// Field 11: `accessed` + #[must_use] + pub fn accessed( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::ResourceAccessRecordView<'_>, + > { + &self.0.reborrow().accessed + } + /// Targets of a multi-resource call that did not apply. Empty when every target + /// succeeded, and empty is also correct for a single-target call, which has + /// nothing partial to report. + /// + /// Successes are deliberately absent: they are already FileChanged facts, and a + /// second record of the same change is a second thing to keep consistent + /// through rewind and redaction. + /// + /// Field 12: `failed_targets` + #[must_use] + pub fn failed_targets( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::TargetOutcomeView<'_>> { + &self.0.reborrow().failed_targets + } + /// How many targets the call set out to apply, recorded so failed_targets can + /// be read as a fraction. Zero for a call with no target list, which is not the + /// same as a call that attempted zero targets and is why the count is here + /// rather than inferred from an empty list. + /// + /// Field 13: `targets_attempted` + #[must_use] + pub fn targets_attempted(&self) -> ::core::option::Option { + self.0.reborrow().targets_attempted + } } impl ::core::convert::From<::buffa::OwnedView>> for ToolCallCompletedOwnedView { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.rs index c831f5db49..942cbf7cce 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.tool_call_completed.rs @@ -81,6 +81,77 @@ pub struct ToolCallCompleted { deserialize_with = "::buffa::json_helpers::null_as_default" )] pub observed: ::buffa::alloc::vec::Vec, + /// Claim-check to this command's captured stdout and stderr, for a tool that + /// executes a process and captured it; unset otherwise, including for a + /// command that ran with capture disabled. + /// + /// It sits here beside `termination` and not inside `result` for the reason + /// `termination` does (D11): captured output is the execution record, while + /// `result` is the transcript the model received. They routinely differ, since + /// what reaches the model is truncated or summarized, and folding raw output + /// into the replay shape would hand a later turn context the original turn + /// never had. + /// + /// Field 9: `output_replay` + #[serde( + rename = "outputReplay", + alias = "output_replay", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub output_replay: ::buffa::MessageField< + CommandOutputReplayRef, + ::buffa::Inline, + >, + /// Set when this call returned a handle to work that outlived the turn. Unset + /// is the ordinary case and means the call's result is its outcome; set means + /// the result is a handle and the outcome arrives later through the operation + /// ledger. + /// + /// Field 10: `detached` + #[serde( + rename = "detached", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub detached: ::buffa::MessageField>, + /// Namespaces this call listed, searched, or otherwise touched, as distinct + /// from the content it read. Empty for a call that accessed no namespace. + /// + /// Field 11: `accessed` + #[serde( + rename = "accessed", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub accessed: ::buffa::alloc::vec::Vec, + /// Targets of a multi-resource call that did not apply. Empty when every target + /// succeeded, and empty is also correct for a single-target call, which has + /// nothing partial to report. + /// + /// Successes are deliberately absent: they are already FileChanged facts, and a + /// second record of the same change is a second thing to keep consistent + /// through rewind and redaction. + /// + /// Field 12: `failed_targets` + #[serde( + rename = "failedTargets", + alias = "failed_targets", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub failed_targets: ::buffa::alloc::vec::Vec, + /// How many targets the call set out to apply, recorded so failed_targets can + /// be read as a fraction. Zero for a call with no target list, which is not the + /// same as a call that attempted zero targets and is why the count is here + /// rather than inferred from an empty list. + /// + /// Field 13: `targets_attempted` + #[serde( + rename = "targetsAttempted", + alias = "targets_attempted", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub targets_attempted: ::core::option::Option, } impl ::core::fmt::Debug for ToolCallCompleted { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -93,6 +164,11 @@ impl ::core::fmt::Debug for ToolCallCompleted { .field("termination", &self.termination) .field("duration", &self.duration) .field("observed", &self.observed) + .field("output_replay", &self.output_replay) + .field("detached", &self.detached) + .field("accessed", &self.accessed) + .field("failed_targets", &self.failed_targets) + .field("targets_attempted", &self.targets_attempted) .finish() } } @@ -103,6 +179,15 @@ impl ToolCallCompleted { /// Format: `type.googleapis.com/` pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.ToolCallCompleted"; } +impl ToolCallCompleted { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::targets_attempted`] to `Some(value)`, consuming and returning `self`. + pub fn with_targets_attempted(mut self, value: u32) -> Self { + self.targets_attempted = Some(value); + self + } +} ::buffa::impl_default_instance!(ToolCallCompleted); impl ::buffa::MessageName for ToolCallCompleted { const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; @@ -160,6 +245,41 @@ impl ::buffa::Message for ToolCallCompleted { += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + inner_size as u64; } + if self.output_replay.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output_replay.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.detached.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.detached.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.accessed { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + for v in &self.failed_targets { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.targets_attempted { + size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64; + } ::buffa::saturate_size(size) } fn write_to( @@ -205,6 +325,41 @@ impl ::buffa::Message for ToolCallCompleted { ); v.write_to(__cache, buf); } + if self.output_replay.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.output_replay.write_to(__cache, buf); + } + if self.detached.is_set() { + ::buffa::types::put_len_delimited_header( + 10u32, + u64::from(__cache.consume_next()), + buf, + ); + self.detached.write_to(__cache, buf); + } + for v in &self.accessed { + ::buffa::types::put_len_delimited_header( + 11u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + for v in &self.failed_targets { + ::buffa::types::put_len_delimited_header( + 12u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(v) = self.targets_attempted { + ::buffa::types::put_uint32_field(13u32, v, buf); + } } fn merge_field( &mut self, @@ -290,6 +445,61 @@ impl ::buffa::Message for ToolCallCompleted { ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; self.observed.push(elem); } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.output_replay.get_or_insert_default(), + buf, + ctx, + )?; + } + 10u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.detached.get_or_insert_default(), + buf, + ctx, + )?; + } + 11u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.accessed.push(elem); + } + 12u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.failed_targets.push(elem); + } + 13u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.targets_attempted = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } _ => { ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; } @@ -305,6 +515,11 @@ impl ::buffa::Message for ToolCallCompleted { self.termination = ::buffa::MessageField::none(); self.duration = ::buffa::MessageField::none(); self.observed.clear(); + self.output_replay = ::buffa::MessageField::none(); + self.detached = ::buffa::MessageField::none(); + self.accessed.clear(); + self.failed_targets.clear(); + self.targets_attempted = ::core::option::Option::None; } } impl ::buffa::json_helpers::ProtoElemJson for ToolCallCompleted { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.__view.rs new file mode 100644 index 0000000000..fe8d26e702 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.__view.rs @@ -0,0 +1,255 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/unarchive_session.proto + +/// UnarchiveSession restores an archived session to the default listing view, +/// recording \[SessionUnarchived\]. +/// +/// Write precondition Any. +#[derive(Clone, Debug, Default)] +pub struct UnarchiveSessionView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UnarchiveSessionView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UnarchiveSessionView<'a> { + type Owned = super::super::UnarchiveSession; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UnarchiveSession { + session_id: self.session_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UnarchiveSessionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UnarchiveSessionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UnarchiveSessionView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "UnarchiveSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.UnarchiveSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UnarchiveSession"; +} +::buffa::impl_default_view_instance!(UnarchiveSessionView); +::buffa::impl_view_reborrow!(UnarchiveSessionView); +/** Self-contained, `'static` owned view of a `UnarchiveSession` message. + + Wraps [`::buffa::OwnedView`]`<`[`UnarchiveSessionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UnarchiveSessionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UnarchiveSessionOwnedView(::buffa::OwnedView>); +impl UnarchiveSessionOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnarchiveSessionOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnarchiveSessionOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UnarchiveSession, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UnarchiveSessionOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`UnarchiveSessionView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UnarchiveSessionView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UnarchiveSession { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for UnarchiveSessionOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + UnarchiveSessionOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UnarchiveSessionOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for UnarchiveSessionOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UnarchiveSession { + type View<'a> = UnarchiveSessionView<'a>; + type ViewHandle = UnarchiveSessionOwnedView; +} +impl ::serde::Serialize for UnarchiveSessionOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.rs new file mode 100644 index 0000000000..82c5b7d9ae --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.unarchive_session.rs @@ -0,0 +1,111 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/unarchive_session.proto + +/// UnarchiveSession restores an archived session to the default listing view, +/// recording \[SessionUnarchived\]. +/// +/// Write precondition Any. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UnarchiveSession { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for UnarchiveSession { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UnarchiveSession").field("session_id", &self.session_id).finish() + } +} +impl UnarchiveSession { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UnarchiveSession"; +} +::buffa::impl_default_instance!(UnarchiveSession); +impl ::buffa::MessageName for UnarchiveSession { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "UnarchiveSession"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.UnarchiveSession"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UnarchiveSession"; +} +impl ::buffa::Message for UnarchiveSession { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for UnarchiveSession { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UNARCHIVE_SESSION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.UnarchiveSession", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.__view.rs new file mode 100644 index 0000000000..ccea2cb8e0 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.__view.rs @@ -0,0 +1,350 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/update_todo.proto + +/// UpdateTodo replaces the agent's task list wholesale, recording +/// \[TodoUpdated\], so the plan is a domain fact rather than something a +/// projection parses out of a tool call's input. +/// +/// Write precondition Any: the fold keeps the highest revision, which is +/// order-independent and so genuinely commuting; ties resolve to the first in +/// fold order. +#[derive(Clone, Debug, Default)] +pub struct UpdateTodoView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The complete list as of this update; readers replace, not merge. + /// + /// Field 2: `items` + pub items: ::buffa::RepeatedView<'a, super::super::__buffa::view::TodoItemView<'a>>, + /// Monotonic per session from the single logical writer, the active + /// attempt's loop. + /// + /// Field 3: `revision` + pub revision: u64, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UpdateTodoView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `revision` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_revision(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UpdateTodoView<'a> { + type Owned = super::super::UpdateTodo; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.revision = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::(), + )?; + view.items + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UpdateTodo { + session_id: self.session_id.to_string(), + items: self + .items + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + revision: self.revision, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UpdateTodoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + for v in &self.items { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.revision) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + for v in &self.items { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(3u32, self.revision, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UpdateTodoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + if !self.items.is_empty() { + __map.serialize_entry("items", &*self.items)?; + } + { + __map + .serialize_entry( + "revision", + &::buffa::json_helpers::ProtoJson(&self.revision), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UpdateTodoView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "UpdateTodo"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.UpdateTodo"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UpdateTodo"; +} +::buffa::impl_default_view_instance!(UpdateTodoView); +::buffa::impl_view_reborrow!(UpdateTodoView); +/** Self-contained, `'static` owned view of a `UpdateTodo` message. + + Wraps [`::buffa::OwnedView`]`<`[`UpdateTodoView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UpdateTodoView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UpdateTodoOwnedView(::buffa::OwnedView>); +impl UpdateTodoOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UpdateTodoOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UpdateTodoOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UpdateTodo, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UpdateTodoOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`UpdateTodoView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UpdateTodoView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UpdateTodo { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The complete list as of this update; readers replace, not merge. + /// + /// Field 2: `items` + #[must_use] + pub fn items( + &self, + ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::TodoItemView<'_>> { + &self.0.reborrow().items + } + /// Monotonic per session from the single logical writer, the active + /// attempt's loop. + /// + /// Field 3: `revision` + #[must_use] + pub fn revision(&self) -> u64 { + self.0.reborrow().revision + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for UpdateTodoOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + UpdateTodoOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UpdateTodoOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for UpdateTodoOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UpdateTodo { + type View<'a> = UpdateTodoView<'a>; + type ViewHandle = UpdateTodoOwnedView; +} +impl ::serde::Serialize for UpdateTodoOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.rs new file mode 100644 index 0000000000..6bf10503da --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.update_todo.rs @@ -0,0 +1,172 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/update_todo.proto + +/// UpdateTodo replaces the agent's task list wholesale, recording +/// \[TodoUpdated\], so the plan is a domain fact rather than something a +/// projection parses out of a tool call's input. +/// +/// Write precondition Any: the fold keeps the highest revision, which is +/// order-independent and so genuinely commuting; ties resolve to the first in +/// fold order. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UpdateTodo { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The complete list as of this update; readers replace, not merge. + /// + /// Field 2: `items` + #[serde( + rename = "items", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub items: ::buffa::alloc::vec::Vec, + /// Monotonic per session from the single logical writer, the active + /// attempt's loop. + /// + /// Field 3: `revision` + #[serde(rename = "revision", with = "::buffa::json_helpers::uint64")] + pub revision: u64, +} +impl ::core::fmt::Debug for UpdateTodo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UpdateTodo") + .field("session_id", &self.session_id) + .field("items", &self.items) + .field("revision", &self.revision) + .finish() + } +} +impl UpdateTodo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UpdateTodo"; +} +::buffa::impl_default_instance!(UpdateTodo); +impl ::buffa::MessageName for UpdateTodo { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "UpdateTodo"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.UpdateTodo"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.UpdateTodo"; +} +impl ::buffa::Message for UpdateTodo { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + for v in &self.items { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::uint64_encoded_len(self.revision) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + for v in &self.items { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + ::buffa::types::put_uint64_field(3u32, self.revision, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.items.push(elem); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.revision = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.items.clear(); + self.revision = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for UpdateTodo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UPDATE_TODO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.UpdateTodo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.__view.rs new file mode 100644 index 0000000000..287964f7e6 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.__view.rs @@ -0,0 +1,1184 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/write_outcome.proto + +/// WriteOutcome is what a caller learned about its own append. +/// +/// Every command response carries one. It exists because the interesting +/// failures of an append are not "it failed": they are the states between +/// success and failure that a boolean cannot express, and that a caller must +/// distinguish before it can decide whether retrying is safe. +/// +/// The reference case is the one this contract is named for. The store accepts +/// an event and the acknowledgment is lost. The caller knows only that it +/// published. It must not report failure, because the event may be committed. +/// It must not blindly retry into a second copy either. It has to be told the +/// outcome is unknown, and then be able to resolve it. +/// +/// There is deliberately no second field naming what the caller should do. +/// Disposition is derived from `state`, because two fields for one fact can +/// disagree, and the one that disagrees is the one a caller trusted. +#[derive(Clone, Debug, Default)] +pub struct WriteOutcomeView<'a> { + /// Field 1: `state` + pub state: ::buffa::EnumValue, + /// Where the write landed. Present for COMMITTED and DEDUPLICATED, and absent + /// for every other state, including UNKNOWN: a position reported for a write + /// nobody confirmed is the exact fiction this message exists to prevent. + /// + /// Field 2: `ordinal` + pub ordinal: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Present when and only when state is UNKNOWN. + /// + /// Field 3: `indeterminate` + pub indeterminate: ::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateWriteView<'a>, + >, + /// Present when and only when state is CONFLICT. + /// + /// Field 4: `conflict` + pub conflict: ::buffa::MessageFieldView< + super::super::__buffa::view::WriteConflictView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> WriteOutcomeView<'a> { + /**Whether required field `state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_state(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for WriteOutcomeView<'a> { + type Owned = super::super::WriteOutcome; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ordinal.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.ordinal = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.indeterminate.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.indeterminate = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.conflict.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.conflict = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::WriteOutcome { + state: self.state, + ordinal: match self.ordinal.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + indeterminate: match self.indeterminate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::IndeterminateWrite, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + conflict: match self.conflict.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::WriteConflict, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for WriteOutcomeView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.ordinal.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ordinal.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.conflict.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.conflict.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.state.to_i32(), buf); + if self.ordinal.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ordinal.write_to(__cache, buf); + } + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.conflict.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.conflict.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for WriteOutcomeView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("state", &self.state)?; + } + { + if let ::core::option::Option::Some(__v) = self.ordinal.as_option() { + __map.serialize_entry("ordinal", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.indeterminate.as_option() { + __map.serialize_entry("indeterminate", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.conflict.as_option() { + __map.serialize_entry("conflict", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for WriteOutcomeView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "WriteOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.WriteOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteOutcome"; +} +::buffa::impl_default_view_instance!(WriteOutcomeView); +::buffa::impl_view_reborrow!(WriteOutcomeView); +/** Self-contained, `'static` owned view of a `WriteOutcome` message. + + Wraps [`::buffa::OwnedView`]`<`[`WriteOutcomeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`WriteOutcomeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct WriteOutcomeOwnedView(::buffa::OwnedView>); +impl WriteOutcomeOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteOutcomeOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteOutcomeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::WriteOutcome, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteOutcomeOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`WriteOutcomeView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &WriteOutcomeView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::WriteOutcome { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `state` + #[must_use] + pub fn state(&self) -> ::buffa::EnumValue { + self.0.reborrow().state + } + /// Where the write landed. Present for COMMITTED and DEDUPLICATED, and absent + /// for every other state, including UNKNOWN: a position reported for a write + /// nobody confirmed is the exact fiction this message exists to prevent. + /// + /// Field 2: `ordinal` + #[must_use] + pub fn ordinal( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().ordinal + } + /// Present when and only when state is UNKNOWN. + /// + /// Field 3: `indeterminate` + #[must_use] + pub fn indeterminate( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::IndeterminateWriteView<'_>, + > { + &self.0.reborrow().indeterminate + } + /// Present when and only when state is CONFLICT. + /// + /// Field 4: `conflict` + #[must_use] + pub fn conflict( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().conflict + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for WriteOutcomeOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + WriteOutcomeOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: WriteOutcomeOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for WriteOutcomeOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::WriteOutcome { + type View<'a> = WriteOutcomeView<'a>; + type ViewHandle = WriteOutcomeOwnedView; +} +impl ::serde::Serialize for WriteOutcomeOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// IndeterminateWrite is why an outcome could not be determined. +/// +/// The reasons are separated because they are resolved differently, and merging +/// them would make a condition that resolves itself on retry indistinguishable +/// from one that never will. +#[derive(Clone, Debug, Default)] +pub struct IndeterminateWriteView<'a> { + /// Field 1: `reason` + pub reason: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> IndeterminateWriteView<'a> { + /**Whether required field `reason` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_reason(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for IndeterminateWriteView<'a> { + type Owned = super::super::IndeterminateWrite; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::IndeterminateWrite { + reason: self.reason, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for IndeterminateWriteView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(2u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for IndeterminateWriteView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("reason", &self.reason)?; + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for IndeterminateWriteView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "IndeterminateWrite"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.IndeterminateWrite"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.IndeterminateWrite"; +} +::buffa::impl_default_view_instance!(IndeterminateWriteView); +::buffa::impl_view_reborrow!(IndeterminateWriteView); +/** Self-contained, `'static` owned view of a `IndeterminateWrite` message. + + Wraps [`::buffa::OwnedView`]`<`[`IndeterminateWriteView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`IndeterminateWriteView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct IndeterminateWriteOwnedView( + ::buffa::OwnedView>, +); +impl IndeterminateWriteOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateWriteOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateWriteOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::IndeterminateWrite, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + IndeterminateWriteOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`IndeterminateWriteView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &IndeterminateWriteView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::IndeterminateWrite { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `reason` + #[must_use] + pub fn reason(&self) -> ::buffa::EnumValue { + self.0.reborrow().reason + } + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for IndeterminateWriteOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + IndeterminateWriteOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: IndeterminateWriteOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for IndeterminateWriteOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::IndeterminateWrite { + type View<'a> = IndeterminateWriteView<'a>; + type ViewHandle = IndeterminateWriteOwnedView; +} +impl ::serde::Serialize for IndeterminateWriteOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// WriteConflict is what the writer believed that the stream did not. +#[derive(Clone, Debug, Default)] +pub struct WriteConflictView<'a> { + /// Field 1: `kind` + pub kind: ::buffa::EnumValue, + /// The head the writer guarded against. Absent when the writer guarded + /// against an empty stream. + /// + /// Field 2: `expected_head` + pub expected_head: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// The head the stream actually had. Absent when it could not be read, which + /// is itself informative: the conflict is real and its shape is not known. + /// + /// Field 3: `observed_head` + pub observed_head: ::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'a>, + >, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 4: `detail` + pub detail: ::core::option::Option<&'a str>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> WriteConflictView<'a> { + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for WriteConflictView<'a> { + type Owned = super::super::WriteConflict; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.expected_head.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.expected_head = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_head.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_head = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.detail = Some(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::WriteConflict { + kind: self.kind, + expected_head: match self.expected_head.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_head: match self.observed_head.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SessionOrdinal, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + detail: self.detail.map(|s| s.to_string()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for WriteConflictView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.expected_head.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_head.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_head.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_head.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if self.expected_head.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_head.write_to(__cache, buf); + } + if self.observed_head.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_head.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for WriteConflictView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("kind", &self.kind)?; + } + { + if let ::core::option::Option::Some(__v) = self.expected_head.as_option() { + __map.serialize_entry("expectedHead", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_head.as_option() { + __map.serialize_entry("observedHead", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.detail { + __map.serialize_entry("detail", __v)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for WriteConflictView<'a> { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "WriteConflict"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.WriteConflict"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteConflict"; +} +::buffa::impl_default_view_instance!(WriteConflictView); +::buffa::impl_view_reborrow!(WriteConflictView); +/** Self-contained, `'static` owned view of a `WriteConflict` message. + + Wraps [`::buffa::OwnedView`]`<`[`WriteConflictView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`WriteConflictView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct WriteConflictOwnedView(::buffa::OwnedView>); +impl WriteConflictOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteConflictOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteConflictOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::WriteConflict, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + WriteConflictOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`WriteConflictView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &WriteConflictView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::WriteConflict { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// The head the writer guarded against. Absent when the writer guarded + /// against an empty stream. + /// + /// Field 2: `expected_head` + #[must_use] + pub fn expected_head( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().expected_head + } + /// The head the stream actually had. Absent when it could not be read, which + /// is itself informative: the conflict is real and its shape is not known. + /// + /// Field 3: `observed_head` + #[must_use] + pub fn observed_head( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SessionOrdinalView<'_>, + > { + &self.0.reborrow().observed_head + } + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 4: `detail` + #[must_use] + pub fn detail(&self) -> ::core::option::Option<&'_ str> { + self.0.reborrow().detail + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for WriteConflictOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + WriteConflictOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: WriteConflictOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for WriteConflictOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::WriteConflict { + type View<'a> = WriteConflictView<'a>; + type ViewHandle = WriteConflictOwnedView; +} +impl ::serde::Serialize for WriteConflictOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.rs new file mode 100644 index 0000000000..1c415cb461 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.session.sessions.v1alpha1.write_outcome.rs @@ -0,0 +1,1227 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/session/sessions/v1alpha1/write_outcome.proto + +/// WriteState is what happened to the append, from the caller's vantage point. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum WriteState { + WRITE_STATE_UNSPECIFIED = 0i32, + /// Definitely not appended. The store rejected the publish before it could + /// reach the log, or refused it outright. Retrying is safe. + WRITE_STATE_NOT_APPENDED = 1i32, + /// Appended and acknowledged. `ordinal` names where. + WRITE_STATE_COMMITTED = 2i32, + /// The identical event was already committed and this append was recognized + /// as a repeat of it. This is a success, not a failure: it is what a correct + /// retry of a lost acknowledgment looks like, and `ordinal` names where the + /// original landed. + /// + /// Distinguished from COMMITTED rather than folded into it because the two + /// mean different things to anything counting side effects. A caller that + /// notifies on every commit would notify twice. + WRITE_STATE_DEDUPLICATED = 3i32, + /// The append was refused because something about the stream disagreed with + /// what the writer believed. Retrying the same command unchanged will fail + /// the same way; the writer must re-read and decide again. + WRITE_STATE_CONFLICT = 4i32, + /// The append outcome is unknown. The event may or may not be committed, and + /// nothing observed so far decides it. This is not a failure and must not be + /// reported as one. + WRITE_STATE_UNKNOWN = 5i32, +} +impl WriteState { + ///Idiomatic alias for [`Self::WRITE_STATE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::WRITE_STATE_UNSPECIFIED; + ///Idiomatic alias for [`Self::WRITE_STATE_NOT_APPENDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const NotAppended: Self = Self::WRITE_STATE_NOT_APPENDED; + ///Idiomatic alias for [`Self::WRITE_STATE_COMMITTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Committed: Self = Self::WRITE_STATE_COMMITTED; + ///Idiomatic alias for [`Self::WRITE_STATE_DEDUPLICATED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Deduplicated: Self = Self::WRITE_STATE_DEDUPLICATED; + ///Idiomatic alias for [`Self::WRITE_STATE_CONFLICT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Conflict: Self = Self::WRITE_STATE_CONFLICT; + ///Idiomatic alias for [`Self::WRITE_STATE_UNKNOWN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unknown: Self = Self::WRITE_STATE_UNKNOWN; +} +impl ::core::default::Default for WriteState { + fn default() -> Self { + Self::WRITE_STATE_UNSPECIFIED + } +} +impl ::serde::Serialize for WriteState { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for WriteState { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = WriteState; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(WriteState)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for WriteState { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for WriteState { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::WRITE_STATE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::WRITE_STATE_NOT_APPENDED), + 2i32 => ::core::option::Option::Some(Self::WRITE_STATE_COMMITTED), + 3i32 => ::core::option::Option::Some(Self::WRITE_STATE_DEDUPLICATED), + 4i32 => ::core::option::Option::Some(Self::WRITE_STATE_CONFLICT), + 5i32 => ::core::option::Option::Some(Self::WRITE_STATE_UNKNOWN), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::WRITE_STATE_UNSPECIFIED => "WRITE_STATE_UNSPECIFIED", + Self::WRITE_STATE_NOT_APPENDED => "WRITE_STATE_NOT_APPENDED", + Self::WRITE_STATE_COMMITTED => "WRITE_STATE_COMMITTED", + Self::WRITE_STATE_DEDUPLICATED => "WRITE_STATE_DEDUPLICATED", + Self::WRITE_STATE_CONFLICT => "WRITE_STATE_CONFLICT", + Self::WRITE_STATE_UNKNOWN => "WRITE_STATE_UNKNOWN", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "WRITE_STATE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::WRITE_STATE_UNSPECIFIED) + } + "WRITE_STATE_NOT_APPENDED" => { + ::core::option::Option::Some(Self::WRITE_STATE_NOT_APPENDED) + } + "WRITE_STATE_COMMITTED" => { + ::core::option::Option::Some(Self::WRITE_STATE_COMMITTED) + } + "WRITE_STATE_DEDUPLICATED" => { + ::core::option::Option::Some(Self::WRITE_STATE_DEDUPLICATED) + } + "WRITE_STATE_CONFLICT" => { + ::core::option::Option::Some(Self::WRITE_STATE_CONFLICT) + } + "WRITE_STATE_UNKNOWN" => { + ::core::option::Option::Some(Self::WRITE_STATE_UNKNOWN) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::WRITE_STATE_UNSPECIFIED, + Self::WRITE_STATE_NOT_APPENDED, + Self::WRITE_STATE_COMMITTED, + Self::WRITE_STATE_DEDUPLICATED, + Self::WRITE_STATE_CONFLICT, + Self::WRITE_STATE_UNKNOWN, + ] + } +} +/// UnknownWriteReason is what prevented the outcome from being determined. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum UnknownWriteReason { + UNKNOWN_WRITE_REASON_UNSPECIFIED = 0i32, + /// The event was published and no acknowledgment was observed within the + /// caller's deadline. The canonical case, and the recoverable one: the + /// deterministic event identity makes a retry either commit or deduplicate. + UNKNOWN_WRITE_REASON_ACK_TIMEOUT = 1i32, + /// An acknowledgment arrived and could not be interpreted. Distinct from a + /// timeout because the store demonstrably responded, so a transport-level + /// retry is answering a different question than a store-level one. + UNKNOWN_WRITE_REASON_ACK_UNREADABLE = 2i32, + /// A multi-event batch acknowledged some members and not others. The stream + /// may now hold a partial batch, which no fold expects, so this resolves by + /// reading the stream rather than by retrying the batch. + UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED = 3i32, + /// The retry arrived after the store's duplicate-detection window elapsed, so + /// the store can no longer tell a repeat from a first attempt. The window is a + /// provisioning knob with a bounded lifetime, not a delivery guarantee. + /// + /// Past it, deduplication moves rather than disappearing: a guarded command + /// re-replays and no-ops on its idempotency key at the aggregate, and an + /// unguarded fact relies on readers collapsing identical ids. So this reason + /// says the outcome is determinable and not determinable from here, which is + /// why it is distinct from ACK_TIMEOUT: it points at a different resolver + /// rather than at a retry the store can no longer make safe. + UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED = 4i32, +} +impl UnknownWriteReason { + ///Idiomatic alias for [`Self::UNKNOWN_WRITE_REASON_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::UNKNOWN_WRITE_REASON_UNSPECIFIED; + ///Idiomatic alias for [`Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AckTimeout: Self = Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT; + ///Idiomatic alias for [`Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const AckUnreadable: Self = Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE; + ///Idiomatic alias for [`Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const BatchPartiallyAcknowledged: Self = Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED; + ///Idiomatic alias for [`Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DeduplicationWindowExpired: Self = Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED; +} +impl ::core::default::Default for UnknownWriteReason { + fn default() -> Self { + Self::UNKNOWN_WRITE_REASON_UNSPECIFIED + } +} +impl ::serde::Serialize for UnknownWriteReason { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for UnknownWriteReason { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = UnknownWriteReason; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(UnknownWriteReason) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for UnknownWriteReason { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for UnknownWriteReason { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT), + 2i32 => { + ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE) + } + 3i32 => { + ::core::option::Option::Some( + Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED, + ) + } + 4i32 => { + ::core::option::Option::Some( + Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::UNKNOWN_WRITE_REASON_UNSPECIFIED => "UNKNOWN_WRITE_REASON_UNSPECIFIED", + Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT => "UNKNOWN_WRITE_REASON_ACK_TIMEOUT", + Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE => { + "UNKNOWN_WRITE_REASON_ACK_UNREADABLE" + } + Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED => { + "UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED" + } + Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED => { + "UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "UNKNOWN_WRITE_REASON_UNSPECIFIED" => { + ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_UNSPECIFIED) + } + "UNKNOWN_WRITE_REASON_ACK_TIMEOUT" => { + ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT) + } + "UNKNOWN_WRITE_REASON_ACK_UNREADABLE" => { + ::core::option::Option::Some(Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE) + } + "UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED" => { + ::core::option::Option::Some( + Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED, + ) + } + "UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED" => { + ::core::option::Option::Some( + Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::UNKNOWN_WRITE_REASON_UNSPECIFIED, + Self::UNKNOWN_WRITE_REASON_ACK_TIMEOUT, + Self::UNKNOWN_WRITE_REASON_ACK_UNREADABLE, + Self::UNKNOWN_WRITE_REASON_BATCH_PARTIALLY_ACKNOWLEDGED, + Self::UNKNOWN_WRITE_REASON_DEDUPLICATION_WINDOW_EXPIRED, + ] + } +} +/// ConflictKind is which disagreement refused the append. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ConflictKind { + CONFLICT_KIND_UNSPECIFIED = 0i32, + /// Optimistic concurrency: the head moved between the read and the append. + /// The ordinary contended case, and the only one that is not a defect. + CONFLICT_KIND_WRONG_EXPECTED_HEAD = 1i32, + /// A creation batch guarded against an empty stream and found one that is + /// not. The identity is already in use. + CONFLICT_KIND_STREAM_ALREADY_EXISTS = 2i32, + /// An event carrying an already-committed identity did not match the + /// committed content. + /// + /// Event identity is derived in part from a caller-supplied idempotency key, + /// so a caller that reuses one key across two different commands produces + /// exactly this. It is reported rather than deduplicated because the store's + /// duplicate detection keys on identity alone: left to itself it would + /// discard the divergent content and acknowledge success, which is silent + /// data loss wearing the shape of idempotency. + CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT = 3i32, + /// The subject the writer resolved belongs to a retired stream incarnation + /// and no longer accepts writes (ADR#0059). The writer must re-resolve rather + /// than retry, because a sealed incarnation refuses every retry forever. + CONFLICT_KIND_INCARNATION_RETIRED = 4i32, +} +impl ConflictKind { + ///Idiomatic alias for [`Self::CONFLICT_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::CONFLICT_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const WrongExpectedHead: Self = Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD; + ///Idiomatic alias for [`Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const StreamAlreadyExists: Self = Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS; + ///Idiomatic alias for [`Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IdentityReusedWithDifferentContent: Self = Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT; + ///Idiomatic alias for [`Self::CONFLICT_KIND_INCARNATION_RETIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const IncarnationRetired: Self = Self::CONFLICT_KIND_INCARNATION_RETIRED; +} +impl ::core::default::Default for ConflictKind { + fn default() -> Self { + Self::CONFLICT_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for ConflictKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ConflictKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ConflictKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(ConflictKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConflictKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ConflictKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::CONFLICT_KIND_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD), + 2i32 => { + ::core::option::Option::Some(Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS) + } + 3i32 => { + ::core::option::Option::Some( + Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT, + ) + } + 4i32 => ::core::option::Option::Some(Self::CONFLICT_KIND_INCARNATION_RETIRED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::CONFLICT_KIND_UNSPECIFIED => "CONFLICT_KIND_UNSPECIFIED", + Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD => { + "CONFLICT_KIND_WRONG_EXPECTED_HEAD" + } + Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS => { + "CONFLICT_KIND_STREAM_ALREADY_EXISTS" + } + Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT => { + "CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT" + } + Self::CONFLICT_KIND_INCARNATION_RETIRED => { + "CONFLICT_KIND_INCARNATION_RETIRED" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "CONFLICT_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::CONFLICT_KIND_UNSPECIFIED) + } + "CONFLICT_KIND_WRONG_EXPECTED_HEAD" => { + ::core::option::Option::Some(Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD) + } + "CONFLICT_KIND_STREAM_ALREADY_EXISTS" => { + ::core::option::Option::Some(Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS) + } + "CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT" => { + ::core::option::Option::Some( + Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT, + ) + } + "CONFLICT_KIND_INCARNATION_RETIRED" => { + ::core::option::Option::Some(Self::CONFLICT_KIND_INCARNATION_RETIRED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::CONFLICT_KIND_UNSPECIFIED, + Self::CONFLICT_KIND_WRONG_EXPECTED_HEAD, + Self::CONFLICT_KIND_STREAM_ALREADY_EXISTS, + Self::CONFLICT_KIND_IDENTITY_REUSED_WITH_DIFFERENT_CONTENT, + Self::CONFLICT_KIND_INCARNATION_RETIRED, + ] + } +} +/// WriteOutcome is what a caller learned about its own append. +/// +/// Every command response carries one. It exists because the interesting +/// failures of an append are not "it failed": they are the states between +/// success and failure that a boolean cannot express, and that a caller must +/// distinguish before it can decide whether retrying is safe. +/// +/// The reference case is the one this contract is named for. The store accepts +/// an event and the acknowledgment is lost. The caller knows only that it +/// published. It must not report failure, because the event may be committed. +/// It must not blindly retry into a second copy either. It has to be told the +/// outcome is unknown, and then be able to resolve it. +/// +/// There is deliberately no second field naming what the caller should do. +/// Disposition is derived from `state`, because two fields for one fact can +/// disagree, and the one that disagrees is the one a caller trusted. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct WriteOutcome { + /// Field 1: `state` + #[serde(rename = "state", with = "::buffa::json_helpers::proto_enum")] + pub state: ::buffa::EnumValue, + /// Where the write landed. Present for COMMITTED and DEDUPLICATED, and absent + /// for every other state, including UNKNOWN: a position reported for a write + /// nobody confirmed is the exact fiction this message exists to prevent. + /// + /// Field 2: `ordinal` + #[serde( + rename = "ordinal", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub ordinal: ::buffa::MessageField>, + /// Present when and only when state is UNKNOWN. + /// + /// Field 3: `indeterminate` + #[serde( + rename = "indeterminate", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub indeterminate: ::buffa::MessageField< + IndeterminateWrite, + ::buffa::Inline, + >, + /// Present when and only when state is CONFLICT. + /// + /// Field 4: `conflict` + #[serde( + rename = "conflict", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub conflict: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for WriteOutcome { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WriteOutcome") + .field("state", &self.state) + .field("ordinal", &self.ordinal) + .field("indeterminate", &self.indeterminate) + .field("conflict", &self.conflict) + .finish() + } +} +impl WriteOutcome { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteOutcome"; +} +::buffa::impl_default_instance!(WriteOutcome); +impl ::buffa::MessageName for WriteOutcome { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "WriteOutcome"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.WriteOutcome"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteOutcome"; +} +impl ::buffa::Message for WriteOutcome { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.ordinal.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ordinal.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.indeterminate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.indeterminate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.conflict.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.conflict.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.state.to_i32(), buf); + if self.ordinal.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.ordinal.write_to(__cache, buf); + } + if self.indeterminate.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.indeterminate.write_to(__cache, buf); + } + if self.conflict.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.conflict.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.ordinal.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.indeterminate.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.conflict.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.state = ::buffa::EnumValue::from(0); + self.ordinal = ::buffa::MessageField::none(); + self.indeterminate = ::buffa::MessageField::none(); + self.conflict = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for WriteOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __WRITE_OUTCOME_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteOutcome", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// IndeterminateWrite is why an outcome could not be determined. +/// +/// The reasons are separated because they are resolved differently, and merging +/// them would make a condition that resolves itself on retry indistinguishable +/// from one that never will. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct IndeterminateWrite { + /// Field 1: `reason` + #[serde(rename = "reason", with = "::buffa::json_helpers::proto_enum")] + pub reason: ::buffa::EnumValue, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 2: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for IndeterminateWrite { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("IndeterminateWrite") + .field("reason", &self.reason) + .field("detail", &self.detail) + .finish() + } +} +impl IndeterminateWrite { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.IndeterminateWrite"; +} +impl IndeterminateWrite { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(IndeterminateWrite); +impl ::buffa::MessageName for IndeterminateWrite { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "IndeterminateWrite"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.IndeterminateWrite"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.IndeterminateWrite"; +} +impl ::buffa::Message for IndeterminateWrite { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.reason.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.reason.to_i32(), buf); + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(2u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.reason = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.reason = ::buffa::EnumValue::from(0); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for IndeterminateWrite { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __INDETERMINATE_WRITE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.IndeterminateWrite", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// WriteConflict is what the writer believed that the stream did not. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct WriteConflict { + /// Field 1: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// The head the writer guarded against. Absent when the writer guarded + /// against an empty stream. + /// + /// Field 2: `expected_head` + #[serde( + rename = "expectedHead", + alias = "expected_head", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub expected_head: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// The head the stream actually had. Absent when it could not be read, which + /// is itself informative: the conflict is real and its shape is not known. + /// + /// Field 3: `observed_head` + #[serde( + rename = "observedHead", + alias = "observed_head", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub observed_head: ::buffa::MessageField< + SessionOrdinal, + ::buffa::Inline, + >, + /// Human-readable, non-contractual. Never parse it. + /// + /// Field 4: `detail` + #[serde(rename = "detail", skip_serializing_if = "::core::option::Option::is_none")] + pub detail: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for WriteConflict { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WriteConflict") + .field("kind", &self.kind) + .field("expected_head", &self.expected_head) + .field("observed_head", &self.observed_head) + .field("detail", &self.detail) + .finish() + } +} +impl WriteConflict { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteConflict"; +} +impl WriteConflict { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::detail`] to `Some(value)`, consuming and returning `self`. + pub fn with_detail( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.detail = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(WriteConflict); +impl ::buffa::MessageName for WriteConflict { + const PACKAGE: &'static str = "trogonai.session.sessions.v1alpha1"; + const NAME: &'static str = "WriteConflict"; + const FULL_NAME: &'static str = "trogonai.session.sessions.v1alpha1.WriteConflict"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteConflict"; +} +impl ::buffa::Message for WriteConflict { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.expected_head.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.expected_head.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_head.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_head.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.detail { + size += 1u64 + ::buffa::types::string_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.kind.to_i32(), buf); + if self.expected_head.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.expected_head.write_to(__cache, buf); + } + if self.observed_head.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_head.write_to(__cache, buf); + } + if let Some(ref v) = self.detail { + ::buffa::types::put_string_field(4u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.expected_head.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_head.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string( + self.detail.get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.kind = ::buffa::EnumValue::from(0); + self.expected_head = ::buffa::MessageField::none(); + self.observed_head = ::buffa::MessageField::none(); + self.detail = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for WriteConflict { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __WRITE_CONFLICT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.session.sessions.v1alpha1.WriteConflict", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.__view.rs new file mode 100644 index 0000000000..bd8551159a --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.__view.rs @@ -0,0 +1,2048 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/usage/settlement/v1alpha1/ledger.proto + +/// The settlement ledger a downstream billing consumer keeps for itself. +/// +/// This lives outside the Session domain on purpose. Session records what was +/// consumed; a billing consumer reads that and turns it into charges, and the +/// retry state of that second job is the consumer's problem, not the session's. +/// Publishing settlement progress back into a session stream would put a +/// downstream system's bookkeeping into a log that is never truncated +/// (ADR#0035 facet 7), so a transient provider outage would leave permanent +/// noise in the history of every session it touched. +/// +/// The one thing this ledger exists for is the case where a charge is published +/// and the acknowledgment is lost. At that moment the consumer knows less than +/// it did before it tried, and the only safe record is one that says so. Every +/// design choice here follows from refusing to let that state be written as +/// either success or failure. +/// +/// UsageRef identifies the usage a settlement is for. +/// +/// It points at the event that recorded consumption, not at a running total. +/// Totals are derived and can be recomputed differently; the fact that a +/// specific ordinal recorded a specific quantity cannot change, which is what +/// makes it usable as an idempotency basis. +#[derive(Clone, Debug, Default)] +pub struct UsageRefView<'a> { + /// Field 1: `session_id` + pub session_id: &'a str, + /// The SessionOrdinal that recorded the consumption. + /// + /// Field 2: `ordinal` + pub ordinal: u64, + /// Which meter this is: a model's input tokens, its output tokens, a tool's + /// invocations. Opaque to this contract. + /// + /// Field 3: `meter` + pub meter: &'a str, + /// Field 4: `quantity` + pub quantity: u64, + /// Who is charged. Carried on the record rather than resolved at settlement + /// time, because an account can be reassigned between consumption and billing + /// and the charge belongs to whoever owned the work when it ran. + /// + /// Field 5: `account_id` + pub account_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> UsageRefView<'a> { + /**Whether required field `session_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_session_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `ordinal` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_ordinal(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `meter` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_meter(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `quantity` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_quantity(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `account_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_account_id(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for UsageRefView<'a> { + type Owned = super::super::UsageRef; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.session_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.ordinal = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.meter = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.quantity = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.account_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::UsageRef { + session_id: self.session_id.to_string(), + ordinal: self.ordinal, + meter: self.meter.to_string(), + quantity: self.quantity, + account_id: self.account_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for UsageRefView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.meter) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.quantity) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.account_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + ::buffa::types::put_string_field(3u32, &self.meter, buf); + ::buffa::types::put_uint64_field(4u32, self.quantity, buf); + ::buffa::types::put_string_field(5u32, &self.account_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for UsageRefView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("sessionId", self.session_id)?; + } + { + __map + .serialize_entry( + "ordinal", + &::buffa::json_helpers::ProtoJson(&self.ordinal), + )?; + } + { + __map.serialize_entry("meter", self.meter)?; + } + { + __map + .serialize_entry( + "quantity", + &::buffa::json_helpers::ProtoJson(&self.quantity), + )?; + } + { + __map.serialize_entry("accountId", self.account_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for UsageRefView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "UsageRef"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.UsageRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.UsageRef"; +} +::buffa::impl_default_view_instance!(UsageRefView); +::buffa::impl_view_reborrow!(UsageRefView); +/** Self-contained, `'static` owned view of a `UsageRef` message. + + Wraps [`::buffa::OwnedView`]`<`[`UsageRefView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`UsageRefView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct UsageRefOwnedView(::buffa::OwnedView>); +impl UsageRefOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok(UsageRefOwnedView(::buffa::OwnedView::decode(bytes)?)) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UsageRefOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::UsageRef, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + UsageRefOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`UsageRefView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &UsageRefView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::UsageRef { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `session_id` + #[must_use] + pub fn session_id(&self) -> &'_ str { + self.0.reborrow().session_id + } + /// The SessionOrdinal that recorded the consumption. + /// + /// Field 2: `ordinal` + #[must_use] + pub fn ordinal(&self) -> u64 { + self.0.reborrow().ordinal + } + /// Which meter this is: a model's input tokens, its output tokens, a tool's + /// invocations. Opaque to this contract. + /// + /// Field 3: `meter` + #[must_use] + pub fn meter(&self) -> &'_ str { + self.0.reborrow().meter + } + /// Field 4: `quantity` + #[must_use] + pub fn quantity(&self) -> u64 { + self.0.reborrow().quantity + } + /// Who is charged. Carried on the record rather than resolved at settlement + /// time, because an account can be reassigned between consumption and billing + /// and the charge belongs to whoever owned the work when it ran. + /// + /// Field 5: `account_id` + #[must_use] + pub fn account_id(&self) -> &'_ str { + self.0.reborrow().account_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for UsageRefOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + UsageRefOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: UsageRefOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for UsageRefOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::UsageRef { + type View<'a> = UsageRefView<'a>; + type ViewHandle = UsageRefOwnedView; +} +impl ::serde::Serialize for UsageRefOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SettlementRecord is one usage fact and everything known about charging for it. +/// +/// The record is written before the charge is published, never after. A ledger +/// written after a successful publish cannot describe the failure it exists to +/// describe: if the process dies between publishing and recording, the only +/// evidence that a charge might exist is gone. +#[derive(Clone, Debug, Default)] +pub struct SettlementRecordView<'a> { + /// Idempotency key and primary identity, derived deterministically from + /// `usage`. + /// + /// Derived from the usage fact and never from the attempt. This is the single + /// property that makes double charging impossible rather than unlikely: a + /// retry recomputes the same key from the same session, ordinal, and meter, + /// so the provider sees the same request it may already have processed. A key + /// minted per attempt would make every retry a new charge, and the retry path + /// is exactly the path a lost acknowledgment forces a consumer down. + /// + /// Field 1: `settlement_id` + pub settlement_id: &'a str, + /// Field 2: `usage` + pub usage: ::buffa::MessageFieldView>, + /// Field 3: `state` + pub state: ::buffa::EnumValue, + /// Publish attempts made. Counts attempts, not charges: the whole point of a + /// stable idempotency key is that these two numbers are allowed to differ. + /// + /// Field 4: `attempt_count` + pub attempt_count: u32, + /// When the consumer durably recorded its intent to charge. + /// + /// Field 5: `intended_at` + pub intended_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// When the most recent publish was attempted. Unset before the first attempt. + /// + /// Field 6: `last_attempt_at` + pub last_attempt_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// When a terminal state was reached. Unset while unresolved. + /// + /// Field 7: `resolved_at` + pub resolved_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// What the provider returned, once it returned anything. Unset for every + /// state that never heard back, which is the same set of states that need + /// reconciling. + /// + /// Field 8: `receipt` + pub receipt: ::buffa::MessageFieldView< + super::super::__buffa::view::ProviderReceiptView<'a>, + >, + /// Set when this settlement needed a human. Its presence is what distinguishes + /// a resolution someone decided from one the protocol reached on its own. + /// + /// Field 9: `incident` + pub incident: ::buffa::MessageFieldView< + super::super::__buffa::view::SettlementIncidentView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SettlementRecordView<'a> { + /**Whether required field `settlement_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_settlement_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `usage` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_usage(&self) -> bool { + self.usage.is_set() + } + /**Whether required field `state` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_state(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `attempt_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_attempt_count(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `intended_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_intended_at(&self) -> bool { + self.intended_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for SettlementRecordView<'a> { + type Owned = super::super::SettlementRecord; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.settlement_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.usage.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.usage = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.attempt_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.intended_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.intended_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.last_attempt_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.last_attempt_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.resolved_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.resolved_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.receipt.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.receipt = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.incident.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.incident = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SettlementRecord { + settlement_id: self.settlement_id.to_string(), + usage: match self.usage.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::UsageRef, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + state: self.state, + attempt_count: self.attempt_count, + intended_at: match self.intended_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + last_attempt_at: match self.last_attempt_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + resolved_at: match self.resolved_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + receipt: match self.receipt.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ProviderReceipt, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + incident: match self.incident.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SettlementIncident, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SettlementRecordView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.settlement_id) as u64; + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.intended_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intended_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.last_attempt_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.last_attempt_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.resolved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.resolved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.receipt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.receipt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.incident.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.incident.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.settlement_id, buf); + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.state.to_i32(), buf); + ::buffa::types::put_uint32_field(4u32, self.attempt_count, buf); + if self.intended_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intended_at.write_to(__cache, buf); + } + if self.last_attempt_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.last_attempt_at.write_to(__cache, buf); + } + if self.resolved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.resolved_at.write_to(__cache, buf); + } + if self.receipt.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.receipt.write_to(__cache, buf); + } + if self.incident.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.incident.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SettlementRecordView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("settlementId", self.settlement_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.usage.as_option() { + __map.serialize_entry("usage", __v)?; + } + } + { + __map.serialize_entry("state", &self.state)?; + } + { + __map + .serialize_entry( + "attemptCount", + &::buffa::json_helpers::ProtoJson(&self.attempt_count), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.intended_at.as_option() { + __map.serialize_entry("intendedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.last_attempt_at.as_option() { + __map.serialize_entry("lastAttemptAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.resolved_at.as_option() { + __map.serialize_entry("resolvedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.receipt.as_option() { + __map.serialize_entry("receipt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.incident.as_option() { + __map.serialize_entry("incident", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SettlementRecordView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "SettlementRecord"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.SettlementRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementRecord"; +} +::buffa::impl_default_view_instance!(SettlementRecordView); +::buffa::impl_view_reborrow!(SettlementRecordView); +/** Self-contained, `'static` owned view of a `SettlementRecord` message. + + Wraps [`::buffa::OwnedView`]`<`[`SettlementRecordView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SettlementRecordView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SettlementRecordOwnedView(::buffa::OwnedView>); +impl SettlementRecordOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementRecordOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementRecordOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SettlementRecord, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementRecordOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SettlementRecordView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SettlementRecordView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SettlementRecord { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Idempotency key and primary identity, derived deterministically from + /// `usage`. + /// + /// Derived from the usage fact and never from the attempt. This is the single + /// property that makes double charging impossible rather than unlikely: a + /// retry recomputes the same key from the same session, ordinal, and meter, + /// so the provider sees the same request it may already have processed. A key + /// minted per attempt would make every retry a new charge, and the retry path + /// is exactly the path a lost acknowledgment forces a consumer down. + /// + /// Field 1: `settlement_id` + #[must_use] + pub fn settlement_id(&self) -> &'_ str { + self.0.reborrow().settlement_id + } + /// Field 2: `usage` + #[must_use] + pub fn usage( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().usage + } + /// Field 3: `state` + #[must_use] + pub fn state(&self) -> ::buffa::EnumValue { + self.0.reborrow().state + } + /// Publish attempts made. Counts attempts, not charges: the whole point of a + /// stable idempotency key is that these two numbers are allowed to differ. + /// + /// Field 4: `attempt_count` + #[must_use] + pub fn attempt_count(&self) -> u32 { + self.0.reborrow().attempt_count + } + /// When the consumer durably recorded its intent to charge. + /// + /// Field 5: `intended_at` + #[must_use] + pub fn intended_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().intended_at + } + /// When the most recent publish was attempted. Unset before the first attempt. + /// + /// Field 6: `last_attempt_at` + #[must_use] + pub fn last_attempt_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().last_attempt_at + } + /// When a terminal state was reached. Unset while unresolved. + /// + /// Field 7: `resolved_at` + #[must_use] + pub fn resolved_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().resolved_at + } + /// What the provider returned, once it returned anything. Unset for every + /// state that never heard back, which is the same set of states that need + /// reconciling. + /// + /// Field 8: `receipt` + #[must_use] + pub fn receipt( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::ProviderReceiptView<'_>, + > { + &self.0.reborrow().receipt + } + /// Set when this settlement needed a human. Its presence is what distinguishes + /// a resolution someone decided from one the protocol reached on its own. + /// + /// Field 9: `incident` + #[must_use] + pub fn incident( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SettlementIncidentView<'_>, + > { + &self.0.reborrow().incident + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SettlementRecordOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SettlementRecordOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SettlementRecordOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SettlementRecordOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SettlementRecord { + type View<'a> = SettlementRecordView<'a>; + type ViewHandle = SettlementRecordOwnedView; +} +impl ::serde::Serialize for SettlementRecordOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ProviderReceipt is the provider's own record of a charge. +#[derive(Clone, Debug, Default)] +pub struct ProviderReceiptView<'a> { + /// The provider's identifier for the charge. Kept so a later reconciliation + /// can ask about this charge specifically rather than searching by amount and + /// time, which is how a reconciliation matches the wrong one. + /// + /// Field 1: `provider_charge_id` + pub provider_charge_id: &'a str, + /// Field 2: `acknowledged_at` + pub acknowledged_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// True when the provider reported this as a repeat of a charge it had already + /// processed under the same idempotency key. + /// + /// Worth recording rather than discarding as a duplicate-suppressed success: + /// it is direct evidence that an earlier attempt landed and its acknowledgment + /// was lost, which is the difference between a system that is retrying + /// correctly and one that is about to be found out at reconciliation. + /// + /// Field 3: `deduplicated` + pub deduplicated: bool, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ProviderReceiptView<'a> { + /**Whether required field `provider_charge_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_provider_charge_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `acknowledged_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_acknowledged_at(&self) -> bool { + self.acknowledged_at.is_set() + } + /**Whether required field `deduplicated` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_deduplicated(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ProviderReceiptView<'a> { + type Owned = super::super::ProviderReceipt; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.provider_charge_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.acknowledged_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.acknowledged_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.deduplicated = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ProviderReceipt { + provider_charge_id: self.provider_charge_id.to_string(), + acknowledged_at: match self.acknowledged_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + deduplicated: self.deduplicated, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ProviderReceiptView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.provider_charge_id) as u64; + if self.acknowledged_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.acknowledged_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.provider_charge_id, buf); + if self.acknowledged_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.acknowledged_at.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.deduplicated, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ProviderReceiptView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("providerChargeId", self.provider_charge_id)?; + } + { + if let ::core::option::Option::Some(__v) = self.acknowledged_at.as_option() { + __map.serialize_entry("acknowledgedAt", __v)?; + } + } + { + __map.serialize_entry("deduplicated", &self.deduplicated)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ProviderReceiptView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ProviderReceipt"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ProviderReceipt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ProviderReceipt"; +} +::buffa::impl_default_view_instance!(ProviderReceiptView); +::buffa::impl_view_reborrow!(ProviderReceiptView); +/** Self-contained, `'static` owned view of a `ProviderReceipt` message. + + Wraps [`::buffa::OwnedView`]`<`[`ProviderReceiptView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ProviderReceiptView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ProviderReceiptOwnedView(::buffa::OwnedView>); +impl ProviderReceiptOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderReceiptOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderReceiptOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ProviderReceipt, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ProviderReceiptOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ProviderReceiptView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ProviderReceiptView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ProviderReceipt { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// The provider's identifier for the charge. Kept so a later reconciliation + /// can ask about this charge specifically rather than searching by amount and + /// time, which is how a reconciliation matches the wrong one. + /// + /// Field 1: `provider_charge_id` + #[must_use] + pub fn provider_charge_id(&self) -> &'_ str { + self.0.reborrow().provider_charge_id + } + /// Field 2: `acknowledged_at` + #[must_use] + pub fn acknowledged_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().acknowledged_at + } + /// True when the provider reported this as a repeat of a charge it had already + /// processed under the same idempotency key. + /// + /// Worth recording rather than discarding as a duplicate-suppressed success: + /// it is direct evidence that an earlier attempt landed and its acknowledgment + /// was lost, which is the difference between a system that is retrying + /// correctly and one that is about to be found out at reconciliation. + /// + /// Field 3: `deduplicated` + #[must_use] + pub fn deduplicated(&self) -> bool { + self.0.reborrow().deduplicated + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ProviderReceiptOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ProviderReceiptOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ProviderReceiptOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ProviderReceiptOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ProviderReceipt { + type View<'a> = ProviderReceiptView<'a>; + type ViewHandle = ProviderReceiptOwnedView; +} +impl ::serde::Serialize for ProviderReceiptOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// SettlementIncident is a settlement that needed a decision. +#[derive(Clone, Debug, Default)] +pub struct SettlementIncidentView<'a> { + /// Field 1: `incident_id` + pub incident_id: &'a str, + /// Field 2: `kind` + pub kind: ::buffa::EnumValue, + /// Field 3: `opened_at` + pub opened_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Unset while open. + /// + /// Field 4: `resolved_at` + pub resolved_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Field 5: `resolution` + pub resolution: ::buffa::EnumValue, + /// Free text for whoever has to read this later. Never parsed. + /// + /// Field 6: `note` + pub note: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> SettlementIncidentView<'a> { + /**Whether required field `incident_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_incident_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `kind` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_kind(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `opened_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_opened_at(&self) -> bool { + self.opened_at.is_set() + } + /**Whether required field `resolution` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_resolution(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `note` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_note(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for SettlementIncidentView<'a> { + type Owned = super::super::SettlementIncident; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.incident_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.kind = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.opened_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.opened_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.resolved_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.resolved_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.resolution = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 4u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.note = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::SettlementIncident { + incident_id: self.incident_id.to_string(), + kind: self.kind, + opened_at: match self.opened_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + resolved_at: match self.resolved_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + resolution: self.resolution, + note: self.note.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for SettlementIncidentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.incident_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.opened_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.opened_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.resolved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.resolved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.resolution.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.note) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.incident_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if self.opened_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.opened_at.write_to(__cache, buf); + } + if self.resolved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.resolved_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(5u32, self.resolution.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.note, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for SettlementIncidentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("incidentId", self.incident_id)?; + } + { + __map.serialize_entry("kind", &self.kind)?; + } + { + if let ::core::option::Option::Some(__v) = self.opened_at.as_option() { + __map.serialize_entry("openedAt", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.resolved_at.as_option() { + __map.serialize_entry("resolvedAt", __v)?; + } + } + { + __map.serialize_entry("resolution", &self.resolution)?; + } + { + __map.serialize_entry("note", self.note)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for SettlementIncidentView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "SettlementIncident"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.SettlementIncident"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementIncident"; +} +::buffa::impl_default_view_instance!(SettlementIncidentView); +::buffa::impl_view_reborrow!(SettlementIncidentView); +/** Self-contained, `'static` owned view of a `SettlementIncident` message. + + Wraps [`::buffa::OwnedView`]`<`[`SettlementIncidentView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`SettlementIncidentView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct SettlementIncidentOwnedView( + ::buffa::OwnedView>, +); +impl SettlementIncidentOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementIncidentOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementIncidentOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::SettlementIncident, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + SettlementIncidentOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`SettlementIncidentView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &SettlementIncidentView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::SettlementIncident { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `incident_id` + #[must_use] + pub fn incident_id(&self) -> &'_ str { + self.0.reborrow().incident_id + } + /// Field 2: `kind` + #[must_use] + pub fn kind(&self) -> ::buffa::EnumValue { + self.0.reborrow().kind + } + /// Field 3: `opened_at` + #[must_use] + pub fn opened_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().opened_at + } + /// Unset while open. + /// + /// Field 4: `resolved_at` + #[must_use] + pub fn resolved_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().resolved_at + } + /// Field 5: `resolution` + #[must_use] + pub fn resolution(&self) -> ::buffa::EnumValue { + self.0.reborrow().resolution + } + /// Free text for whoever has to read this later. Never parsed. + /// + /// Field 6: `note` + #[must_use] + pub fn note(&self) -> &'_ str { + self.0.reborrow().note + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for SettlementIncidentOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + SettlementIncidentOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: SettlementIncidentOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for SettlementIncidentOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::SettlementIncident { + type View<'a> = SettlementIncidentView<'a>; + type ViewHandle = SettlementIncidentOwnedView; +} +impl ::serde::Serialize for SettlementIncidentOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.rs new file mode 100644 index 0000000000..aa10ea6c37 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.ledger.rs @@ -0,0 +1,1618 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/usage/settlement/v1alpha1/ledger.proto + +/// SettlementState is how far a settlement got, and what a retry is allowed to +/// assume. +/// +/// The zero value is the one that blocks a blind retry, because the failure mode +/// this ledger prevents is a retry that assumes nothing happened. A reader that +/// does not recognize a variant must reconcile before charging again. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum SettlementState { + /// Unknown state. Treat as UNKNOWN: reconcile before any further publish. + SETTLEMENT_STATE_UNSPECIFIED = 0i32, + /// Intent is durable and no publish has been attempted. + /// + /// The only state that lets a consumer conclude no charge exists. It holds + /// because the transition to IN_FLIGHT is itself durable and happens before + /// the publish call, so a crash cannot skip past it. + SETTLEMENT_STATE_INTENDED = 1i32, + /// A publish is in progress. + /// + /// Not durable across a restart in the sense a reader might expect: a consumer + /// recovering from a crash has no in-progress calls, so every record found in + /// this state on startup is moved to UNKNOWN. Its useful life is entirely + /// within one process lifetime. + SETTLEMENT_STATE_IN_FLIGHT = 2i32, + /// A publish was attempted and its outcome was never observed. + /// + /// This is the state the ledger is for. The charge may exist and may not, and + /// the consumer must not guess in either direction: republishing under the + /// same idempotency key is safe, and treating it as failed and re-deriving a + /// key is the double charge. + SETTLEMENT_STATE_UNKNOWN = 3i32, + /// The provider confirmed the charge. Terminal. + SETTLEMENT_STATE_SETTLED = 4i32, + /// The provider refused the charge and said so. Terminal, and not a retry: + /// a refusal that is republished unchanged is refused again. + SETTLEMENT_STATE_REJECTED = 5i32, + /// Closed without settling, by a decision recorded in `incident`. Terminal. + /// + /// Reachable only through an incident, so nothing in the automated path can + /// reach it. A consumer that could abandon a charge on its own would be one + /// that quietly stops billing under sustained provider failure. + SETTLEMENT_STATE_ABANDONED = 6i32, +} +impl SettlementState { + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::SETTLEMENT_STATE_UNSPECIFIED; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_INTENDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Intended: Self = Self::SETTLEMENT_STATE_INTENDED; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_IN_FLIGHT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const InFlight: Self = Self::SETTLEMENT_STATE_IN_FLIGHT; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_UNKNOWN`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unknown: Self = Self::SETTLEMENT_STATE_UNKNOWN; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_SETTLED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Settled: Self = Self::SETTLEMENT_STATE_SETTLED; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_REJECTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Rejected: Self = Self::SETTLEMENT_STATE_REJECTED; + ///Idiomatic alias for [`Self::SETTLEMENT_STATE_ABANDONED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Abandoned: Self = Self::SETTLEMENT_STATE_ABANDONED; +} +impl ::core::default::Default for SettlementState { + fn default() -> Self { + Self::SETTLEMENT_STATE_UNSPECIFIED + } +} +impl ::serde::Serialize for SettlementState { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for SettlementState { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = SettlementState; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(SettlementState) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SettlementState { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for SettlementState { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_INTENDED), + 2i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_IN_FLIGHT), + 3i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_UNKNOWN), + 4i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_SETTLED), + 5i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_REJECTED), + 6i32 => ::core::option::Option::Some(Self::SETTLEMENT_STATE_ABANDONED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::SETTLEMENT_STATE_UNSPECIFIED => "SETTLEMENT_STATE_UNSPECIFIED", + Self::SETTLEMENT_STATE_INTENDED => "SETTLEMENT_STATE_INTENDED", + Self::SETTLEMENT_STATE_IN_FLIGHT => "SETTLEMENT_STATE_IN_FLIGHT", + Self::SETTLEMENT_STATE_UNKNOWN => "SETTLEMENT_STATE_UNKNOWN", + Self::SETTLEMENT_STATE_SETTLED => "SETTLEMENT_STATE_SETTLED", + Self::SETTLEMENT_STATE_REJECTED => "SETTLEMENT_STATE_REJECTED", + Self::SETTLEMENT_STATE_ABANDONED => "SETTLEMENT_STATE_ABANDONED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "SETTLEMENT_STATE_UNSPECIFIED" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_UNSPECIFIED) + } + "SETTLEMENT_STATE_INTENDED" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_INTENDED) + } + "SETTLEMENT_STATE_IN_FLIGHT" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_IN_FLIGHT) + } + "SETTLEMENT_STATE_UNKNOWN" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_UNKNOWN) + } + "SETTLEMENT_STATE_SETTLED" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_SETTLED) + } + "SETTLEMENT_STATE_REJECTED" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_REJECTED) + } + "SETTLEMENT_STATE_ABANDONED" => { + ::core::option::Option::Some(Self::SETTLEMENT_STATE_ABANDONED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::SETTLEMENT_STATE_UNSPECIFIED, + Self::SETTLEMENT_STATE_INTENDED, + Self::SETTLEMENT_STATE_IN_FLIGHT, + Self::SETTLEMENT_STATE_UNKNOWN, + Self::SETTLEMENT_STATE_SETTLED, + Self::SETTLEMENT_STATE_REJECTED, + Self::SETTLEMENT_STATE_ABANDONED, + ] + } +} +/// IncidentKind is why a settlement stopped being something the protocol could +/// finish by itself. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum IncidentKind { + INCIDENT_KIND_UNSPECIFIED = 0i32, + /// A settlement sat in UNKNOWN past the window in which the provider could + /// still be asked about it. Someone has to establish whether the money moved. + INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED = 1i32, + /// Two settled records were found for the same usage. Either the idempotency + /// key was not derived deterministically, or the provider processed the same + /// key twice, and both call for a refund rather than a retry. + INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED = 2i32, + /// The provider refused in a way that will not resolve by retrying: a closed + /// account, an unrecognized meter, a rejected currency. + INCIDENT_KIND_PROVIDER_REFUSED = 3i32, + /// The session this usage belongs to no longer shows it, because a rewind, + /// compaction, or redaction removed the ordinal from effective history. + /// + /// Opened as an incident rather than reversed automatically, because usage is + /// not part of effective history. Tokens that were spent were spent, and + /// rewinding a session does not un-consume them, so a ledger that followed + /// effective history would refund real compute every time a user backed up a + /// turn. What is genuinely ambiguous is whether the removal was a correction + /// or a privacy action, and that is a question for a person. + INCIDENT_KIND_USAGE_RETRACTED = 4i32, +} +impl IncidentKind { + ///Idiomatic alias for [`Self::INCIDENT_KIND_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::INCIDENT_KIND_UNSPECIFIED; + ///Idiomatic alias for [`Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UnknownOutcomeExpired: Self = Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED; + ///Idiomatic alias for [`Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const DuplicateChargeDetected: Self = Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED; + ///Idiomatic alias for [`Self::INCIDENT_KIND_PROVIDER_REFUSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProviderRefused: Self = Self::INCIDENT_KIND_PROVIDER_REFUSED; + ///Idiomatic alias for [`Self::INCIDENT_KIND_USAGE_RETRACTED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const UsageRetracted: Self = Self::INCIDENT_KIND_USAGE_RETRACTED; +} +impl ::core::default::Default for IncidentKind { + fn default() -> Self { + Self::INCIDENT_KIND_UNSPECIFIED + } +} +impl ::serde::Serialize for IncidentKind { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for IncidentKind { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = IncidentKind; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(IncidentKind)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for IncidentKind { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for IncidentKind { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::INCIDENT_KIND_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED) + } + 2i32 => { + ::core::option::Option::Some( + Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED, + ) + } + 3i32 => ::core::option::Option::Some(Self::INCIDENT_KIND_PROVIDER_REFUSED), + 4i32 => ::core::option::Option::Some(Self::INCIDENT_KIND_USAGE_RETRACTED), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::INCIDENT_KIND_UNSPECIFIED => "INCIDENT_KIND_UNSPECIFIED", + Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED => { + "INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED" + } + Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED => { + "INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED" + } + Self::INCIDENT_KIND_PROVIDER_REFUSED => "INCIDENT_KIND_PROVIDER_REFUSED", + Self::INCIDENT_KIND_USAGE_RETRACTED => "INCIDENT_KIND_USAGE_RETRACTED", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "INCIDENT_KIND_UNSPECIFIED" => { + ::core::option::Option::Some(Self::INCIDENT_KIND_UNSPECIFIED) + } + "INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED" => { + ::core::option::Option::Some(Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED) + } + "INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED" => { + ::core::option::Option::Some( + Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED, + ) + } + "INCIDENT_KIND_PROVIDER_REFUSED" => { + ::core::option::Option::Some(Self::INCIDENT_KIND_PROVIDER_REFUSED) + } + "INCIDENT_KIND_USAGE_RETRACTED" => { + ::core::option::Option::Some(Self::INCIDENT_KIND_USAGE_RETRACTED) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::INCIDENT_KIND_UNSPECIFIED, + Self::INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED, + Self::INCIDENT_KIND_DUPLICATE_CHARGE_DETECTED, + Self::INCIDENT_KIND_PROVIDER_REFUSED, + Self::INCIDENT_KIND_USAGE_RETRACTED, + ] + } +} +/// IncidentResolution is what was decided, once someone decided. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum IncidentResolution { + /// Still open. The zero value, so an incident record that was never resolved + /// cannot read as one that was. + INCIDENT_RESOLUTION_UNSPECIFIED = 0i32, + /// Established that the charge exists. The record moves to SETTLED. + INCIDENT_RESOLUTION_CONFIRMED_CHARGED = 1i32, + /// Established that no charge exists. The record returns to INTENDED and may + /// be published again. + INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED = 2i32, + /// A charge existed and was reversed. + INCIDENT_RESOLUTION_REFUNDED = 3i32, + /// Closed without charging and without further attempts. The record moves to + /// ABANDONED. + INCIDENT_RESOLUTION_WRITTEN_OFF = 4i32, +} +impl IncidentResolution { + ///Idiomatic alias for [`Self::INCIDENT_RESOLUTION_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::INCIDENT_RESOLUTION_UNSPECIFIED; + ///Idiomatic alias for [`Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ConfirmedCharged: Self = Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED; + ///Idiomatic alias for [`Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ConfirmedNotCharged: Self = Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED; + ///Idiomatic alias for [`Self::INCIDENT_RESOLUTION_REFUNDED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Refunded: Self = Self::INCIDENT_RESOLUTION_REFUNDED; + ///Idiomatic alias for [`Self::INCIDENT_RESOLUTION_WRITTEN_OFF`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const WrittenOff: Self = Self::INCIDENT_RESOLUTION_WRITTEN_OFF; +} +impl ::core::default::Default for IncidentResolution { + fn default() -> Self { + Self::INCIDENT_RESOLUTION_UNSPECIFIED + } +} +impl ::serde::Serialize for IncidentResolution { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for IncidentResolution { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = IncidentResolution; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", stringify!(IncidentResolution) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for IncidentResolution { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for IncidentResolution { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_UNSPECIFIED), + 1i32 => { + ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED) + } + 2i32 => { + ::core::option::Option::Some( + Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED, + ) + } + 3i32 => ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_REFUNDED), + 4i32 => ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_WRITTEN_OFF), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::INCIDENT_RESOLUTION_UNSPECIFIED => "INCIDENT_RESOLUTION_UNSPECIFIED", + Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED => { + "INCIDENT_RESOLUTION_CONFIRMED_CHARGED" + } + Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED => { + "INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED" + } + Self::INCIDENT_RESOLUTION_REFUNDED => "INCIDENT_RESOLUTION_REFUNDED", + Self::INCIDENT_RESOLUTION_WRITTEN_OFF => "INCIDENT_RESOLUTION_WRITTEN_OFF", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "INCIDENT_RESOLUTION_UNSPECIFIED" => { + ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_UNSPECIFIED) + } + "INCIDENT_RESOLUTION_CONFIRMED_CHARGED" => { + ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED) + } + "INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED" => { + ::core::option::Option::Some( + Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED, + ) + } + "INCIDENT_RESOLUTION_REFUNDED" => { + ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_REFUNDED) + } + "INCIDENT_RESOLUTION_WRITTEN_OFF" => { + ::core::option::Option::Some(Self::INCIDENT_RESOLUTION_WRITTEN_OFF) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::INCIDENT_RESOLUTION_UNSPECIFIED, + Self::INCIDENT_RESOLUTION_CONFIRMED_CHARGED, + Self::INCIDENT_RESOLUTION_CONFIRMED_NOT_CHARGED, + Self::INCIDENT_RESOLUTION_REFUNDED, + Self::INCIDENT_RESOLUTION_WRITTEN_OFF, + ] + } +} +/// The settlement ledger a downstream billing consumer keeps for itself. +/// +/// This lives outside the Session domain on purpose. Session records what was +/// consumed; a billing consumer reads that and turns it into charges, and the +/// retry state of that second job is the consumer's problem, not the session's. +/// Publishing settlement progress back into a session stream would put a +/// downstream system's bookkeeping into a log that is never truncated +/// (ADR#0035 facet 7), so a transient provider outage would leave permanent +/// noise in the history of every session it touched. +/// +/// The one thing this ledger exists for is the case where a charge is published +/// and the acknowledgment is lost. At that moment the consumer knows less than +/// it did before it tried, and the only safe record is one that says so. Every +/// design choice here follows from refusing to let that state be written as +/// either success or failure. +/// +/// UsageRef identifies the usage a settlement is for. +/// +/// It points at the event that recorded consumption, not at a running total. +/// Totals are derived and can be recomputed differently; the fact that a +/// specific ordinal recorded a specific quantity cannot change, which is what +/// makes it usable as an idempotency basis. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UsageRef { + /// Field 1: `session_id` + #[serde( + rename = "sessionId", + alias = "session_id", + with = "::buffa::json_helpers::proto_string" + )] + pub session_id: ::buffa::alloc::string::String, + /// The SessionOrdinal that recorded the consumption. + /// + /// Field 2: `ordinal` + #[serde(rename = "ordinal", with = "::buffa::json_helpers::uint64")] + pub ordinal: u64, + /// Which meter this is: a model's input tokens, its output tokens, a tool's + /// invocations. Opaque to this contract. + /// + /// Field 3: `meter` + #[serde(rename = "meter", with = "::buffa::json_helpers::proto_string")] + pub meter: ::buffa::alloc::string::String, + /// Field 4: `quantity` + #[serde(rename = "quantity", with = "::buffa::json_helpers::uint64")] + pub quantity: u64, + /// Who is charged. Carried on the record rather than resolved at settlement + /// time, because an account can be reassigned between consumption and billing + /// and the charge belongs to whoever owned the work when it ran. + /// + /// Field 5: `account_id` + #[serde( + rename = "accountId", + alias = "account_id", + with = "::buffa::json_helpers::proto_string" + )] + pub account_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for UsageRef { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UsageRef") + .field("session_id", &self.session_id) + .field("ordinal", &self.ordinal) + .field("meter", &self.meter) + .field("quantity", &self.quantity) + .field("account_id", &self.account_id) + .finish() + } +} +impl UsageRef { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.UsageRef"; +} +::buffa::impl_default_instance!(UsageRef); +impl ::buffa::MessageName for UsageRef { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "UsageRef"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.UsageRef"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.UsageRef"; +} +impl ::buffa::Message for UsageRef { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.session_id) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.meter) as u64; + size += 1u64 + ::buffa::types::uint64_encoded_len(self.quantity) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.account_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.session_id, buf); + ::buffa::types::put_uint64_field(2u32, self.ordinal, buf); + ::buffa::types::put_string_field(3u32, &self.meter, buf); + ::buffa::types::put_uint64_field(4u32, self.quantity, buf); + ::buffa::types::put_string_field(5u32, &self.account_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.session_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.ordinal = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.meter, buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.quantity = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.account_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.session_id.clear(); + self.ordinal = 0u64; + self.meter.clear(); + self.quantity = 0u64; + self.account_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for UsageRef { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __USAGE_REF_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.UsageRef", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SettlementRecord is one usage fact and everything known about charging for it. +/// +/// The record is written before the charge is published, never after. A ledger +/// written after a successful publish cannot describe the failure it exists to +/// describe: if the process dies between publishing and recording, the only +/// evidence that a charge might exist is gone. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SettlementRecord { + /// Idempotency key and primary identity, derived deterministically from + /// `usage`. + /// + /// Derived from the usage fact and never from the attempt. This is the single + /// property that makes double charging impossible rather than unlikely: a + /// retry recomputes the same key from the same session, ordinal, and meter, + /// so the provider sees the same request it may already have processed. A key + /// minted per attempt would make every retry a new charge, and the retry path + /// is exactly the path a lost acknowledgment forces a consumer down. + /// + /// Field 1: `settlement_id` + #[serde( + rename = "settlementId", + alias = "settlement_id", + with = "::buffa::json_helpers::proto_string" + )] + pub settlement_id: ::buffa::alloc::string::String, + /// Field 2: `usage` + #[serde(rename = "usage")] + pub usage: ::buffa::MessageField>, + /// Field 3: `state` + #[serde(rename = "state", with = "::buffa::json_helpers::proto_enum")] + pub state: ::buffa::EnumValue, + /// Publish attempts made. Counts attempts, not charges: the whole point of a + /// stable idempotency key is that these two numbers are allowed to differ. + /// + /// Field 4: `attempt_count` + #[serde( + rename = "attemptCount", + alias = "attempt_count", + with = "::buffa::json_helpers::uint32" + )] + pub attempt_count: u32, + /// When the consumer durably recorded its intent to charge. + /// + /// Field 5: `intended_at` + #[serde(rename = "intendedAt", alias = "intended_at")] + pub intended_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// When the most recent publish was attempted. Unset before the first attempt. + /// + /// Field 6: `last_attempt_at` + #[serde( + rename = "lastAttemptAt", + alias = "last_attempt_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub last_attempt_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// When a terminal state was reached. Unset while unresolved. + /// + /// Field 7: `resolved_at` + #[serde( + rename = "resolvedAt", + alias = "resolved_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub resolved_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// What the provider returned, once it returned anything. Unset for every + /// state that never heard back, which is the same set of states that need + /// reconciling. + /// + /// Field 8: `receipt` + #[serde( + rename = "receipt", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub receipt: ::buffa::MessageField< + ProviderReceipt, + ::buffa::Inline, + >, + /// Set when this settlement needed a human. Its presence is what distinguishes + /// a resolution someone decided from one the protocol reached on its own. + /// + /// Field 9: `incident` + #[serde( + rename = "incident", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub incident: ::buffa::MessageField< + SettlementIncident, + ::buffa::Inline, + >, +} +impl ::core::fmt::Debug for SettlementRecord { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SettlementRecord") + .field("settlement_id", &self.settlement_id) + .field("usage", &self.usage) + .field("state", &self.state) + .field("attempt_count", &self.attempt_count) + .field("intended_at", &self.intended_at) + .field("last_attempt_at", &self.last_attempt_at) + .field("resolved_at", &self.resolved_at) + .field("receipt", &self.receipt) + .field("incident", &self.incident) + .finish() + } +} +impl SettlementRecord { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementRecord"; +} +::buffa::impl_default_instance!(SettlementRecord); +impl ::buffa::MessageName for SettlementRecord { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "SettlementRecord"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.SettlementRecord"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementRecord"; +} +impl ::buffa::Message for SettlementRecord { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.settlement_id) as u64; + if self.usage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.usage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.state.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.attempt_count) as u64; + if self.intended_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.intended_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.last_attempt_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.last_attempt_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.resolved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.resolved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.receipt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.receipt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.incident.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.incident.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.settlement_id, buf); + if self.usage.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.usage.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(3u32, self.state.to_i32(), buf); + ::buffa::types::put_uint32_field(4u32, self.attempt_count, buf); + if self.intended_at.is_set() { + ::buffa::types::put_len_delimited_header( + 5u32, + u64::from(__cache.consume_next()), + buf, + ); + self.intended_at.write_to(__cache, buf); + } + if self.last_attempt_at.is_set() { + ::buffa::types::put_len_delimited_header( + 6u32, + u64::from(__cache.consume_next()), + buf, + ); + self.last_attempt_at.write_to(__cache, buf); + } + if self.resolved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 7u32, + u64::from(__cache.consume_next()), + buf, + ); + self.resolved_at.write_to(__cache, buf); + } + if self.receipt.is_set() { + ::buffa::types::put_len_delimited_header( + 8u32, + u64::from(__cache.consume_next()), + buf, + ); + self.receipt.write_to(__cache, buf); + } + if self.incident.is_set() { + ::buffa::types::put_len_delimited_header( + 9u32, + u64::from(__cache.consume_next()), + buf, + ); + self.incident.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.settlement_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.usage.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.state = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.attempt_count = ::buffa::types::decode_uint32(buf)?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.intended_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.last_attempt_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.resolved_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 8u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.receipt.get_or_insert_default(), + buf, + ctx, + )?; + } + 9u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.incident.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.settlement_id.clear(); + self.usage = ::buffa::MessageField::none(); + self.state = ::buffa::EnumValue::from(0); + self.attempt_count = 0u32; + self.intended_at = ::buffa::MessageField::none(); + self.last_attempt_at = ::buffa::MessageField::none(); + self.resolved_at = ::buffa::MessageField::none(); + self.receipt = ::buffa::MessageField::none(); + self.incident = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SettlementRecord { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SETTLEMENT_RECORD_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementRecord", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ProviderReceipt is the provider's own record of a charge. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ProviderReceipt { + /// The provider's identifier for the charge. Kept so a later reconciliation + /// can ask about this charge specifically rather than searching by amount and + /// time, which is how a reconciliation matches the wrong one. + /// + /// Field 1: `provider_charge_id` + #[serde( + rename = "providerChargeId", + alias = "provider_charge_id", + with = "::buffa::json_helpers::proto_string" + )] + pub provider_charge_id: ::buffa::alloc::string::String, + /// Field 2: `acknowledged_at` + #[serde(rename = "acknowledgedAt", alias = "acknowledged_at")] + pub acknowledged_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// True when the provider reported this as a repeat of a charge it had already + /// processed under the same idempotency key. + /// + /// Worth recording rather than discarding as a duplicate-suppressed success: + /// it is direct evidence that an earlier attempt landed and its acknowledgment + /// was lost, which is the difference between a system that is retrying + /// correctly and one that is about to be found out at reconciliation. + /// + /// Field 3: `deduplicated` + #[serde(rename = "deduplicated", with = "::buffa::json_helpers::proto_bool")] + pub deduplicated: bool, +} +impl ::core::fmt::Debug for ProviderReceipt { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProviderReceipt") + .field("provider_charge_id", &self.provider_charge_id) + .field("acknowledged_at", &self.acknowledged_at) + .field("deduplicated", &self.deduplicated) + .finish() + } +} +impl ProviderReceipt { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ProviderReceipt"; +} +::buffa::impl_default_instance!(ProviderReceipt); +impl ::buffa::MessageName for ProviderReceipt { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ProviderReceipt"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ProviderReceipt"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ProviderReceipt"; +} +impl ::buffa::Message for ProviderReceipt { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size + += 1u64 + + ::buffa::types::string_encoded_len(&self.provider_charge_id) as u64; + if self.acknowledged_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.acknowledged_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.provider_charge_id, buf); + if self.acknowledged_at.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.acknowledged_at.write_to(__cache, buf); + } + ::buffa::types::put_bool_field(3u32, self.deduplicated, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.provider_charge_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.acknowledged_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.deduplicated = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.provider_charge_id.clear(); + self.acknowledged_at = ::buffa::MessageField::none(); + self.deduplicated = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ProviderReceipt { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __PROVIDER_RECEIPT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ProviderReceipt", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// SettlementIncident is a settlement that needed a decision. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SettlementIncident { + /// Field 1: `incident_id` + #[serde( + rename = "incidentId", + alias = "incident_id", + with = "::buffa::json_helpers::proto_string" + )] + pub incident_id: ::buffa::alloc::string::String, + /// Field 2: `kind` + #[serde(rename = "kind", with = "::buffa::json_helpers::proto_enum")] + pub kind: ::buffa::EnumValue, + /// Field 3: `opened_at` + #[serde(rename = "openedAt", alias = "opened_at")] + pub opened_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// Unset while open. + /// + /// Field 4: `resolved_at` + #[serde( + rename = "resolvedAt", + alias = "resolved_at", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub resolved_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// Field 5: `resolution` + #[serde(rename = "resolution", with = "::buffa::json_helpers::proto_enum")] + pub resolution: ::buffa::EnumValue, + /// Free text for whoever has to read this later. Never parsed. + /// + /// Field 6: `note` + #[serde(rename = "note", with = "::buffa::json_helpers::proto_string")] + pub note: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for SettlementIncident { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SettlementIncident") + .field("incident_id", &self.incident_id) + .field("kind", &self.kind) + .field("opened_at", &self.opened_at) + .field("resolved_at", &self.resolved_at) + .field("resolution", &self.resolution) + .field("note", &self.note) + .finish() + } +} +impl SettlementIncident { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementIncident"; +} +::buffa::impl_default_instance!(SettlementIncident); +impl ::buffa::MessageName for SettlementIncident { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "SettlementIncident"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.SettlementIncident"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementIncident"; +} +impl ::buffa::Message for SettlementIncident { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.incident_id) as u64; + { + let val = self.kind.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.opened_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.opened_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.resolved_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.resolved_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + { + let val = self.resolution.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + size += 1u64 + ::buffa::types::string_encoded_len(&self.note) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.incident_id, buf); + ::buffa::types::put_int32_field(2u32, self.kind.to_i32(), buf); + if self.opened_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.opened_at.write_to(__cache, buf); + } + if self.resolved_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.resolved_at.write_to(__cache, buf); + } + ::buffa::types::put_int32_field(5u32, self.resolution.to_i32(), buf); + ::buffa::types::put_string_field(6u32, &self.note, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.incident_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.kind = ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.opened_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.resolved_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.resolution = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.note, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.incident_id.clear(); + self.kind = ::buffa::EnumValue::from(0); + self.opened_at = ::buffa::MessageField::none(); + self.resolved_at = ::buffa::MessageField::none(); + self.resolution = ::buffa::EnumValue::from(0); + self.note.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SettlementIncident { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SETTLEMENT_INCIDENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.SettlementIncident", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.mod.rs new file mode 100644 index 0000000000..a4c7f9c5da --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.mod.rs @@ -0,0 +1,80 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +include!("trogonai.usage.settlement.v1alpha1.ledger.rs"); +include!("trogonai.usage.settlement.v1alpha1.recovery.rs"); +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + include!("trogonai.usage.settlement.v1alpha1.ledger.__view.rs"); + include!("trogonai.usage.settlement.v1alpha1.recovery.__view.rs"); + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__USAGE_REF_JSON_ANY); + reg.register_json_any(super::__SETTLEMENT_RECORD_JSON_ANY); + reg.register_json_any(super::__PROVIDER_RECEIPT_JSON_ANY); + reg.register_json_any(super::__SETTLEMENT_INCIDENT_JSON_ANY); + reg.register_json_any(super::__CONSUMER_CHECKPOINT_JSON_ANY); + reg.register_json_any(super::__SCAN_OPEN_SETTLEMENTS_REQUEST_JSON_ANY); + reg.register_json_any(super::__SCAN_OPEN_SETTLEMENTS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SCAN_COVERAGE_JSON_ANY); + reg.register_json_any(super::__RECONCILE_SETTLEMENT_REQUEST_JSON_ANY); + reg.register_json_any(super::__RECONCILE_SETTLEMENT_RESPONSE_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::UsageRefView; +#[doc(inline)] +pub use self::__buffa::view::UsageRefOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SettlementRecordView; +#[doc(inline)] +pub use self::__buffa::view::SettlementRecordOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ProviderReceiptView; +#[doc(inline)] +pub use self::__buffa::view::ProviderReceiptOwnedView; +#[doc(inline)] +pub use self::__buffa::view::SettlementIncidentView; +#[doc(inline)] +pub use self::__buffa::view::SettlementIncidentOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ConsumerCheckpointView; +#[doc(inline)] +pub use self::__buffa::view::ConsumerCheckpointOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ScanOpenSettlementsRequestView; +#[doc(inline)] +pub use self::__buffa::view::ScanOpenSettlementsRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ScanOpenSettlementsResponseView; +#[doc(inline)] +pub use self::__buffa::view::ScanOpenSettlementsResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ScanCoverageView; +#[doc(inline)] +pub use self::__buffa::view::ScanCoverageOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileSettlementRequestView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileSettlementRequestOwnedView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileSettlementResponseView; +#[doc(inline)] +pub use self::__buffa::view::ReconcileSettlementResponseOwnedView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.__view.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.__view.rs new file mode 100644 index 0000000000..1904c351bf --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.__view.rs @@ -0,0 +1,2553 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/usage/settlement/v1alpha1/recovery.proto + +/// Recovery for a billing consumer: where it got to, and what it left open. +/// +/// ConsumerCheckpoint is how far a billing consumer has read its source. +/// +/// Consumption position and settlement state are tracked separately, and that +/// separation is deliberate. If the watermark could not advance past an +/// unresolved settlement, one charge stuck behind a provider outage would stop +/// billing for everything after it, and the outage would turn into a backlog +/// measured in whatever the busiest tenant produced meanwhile. The watermark +/// says what has been turned into ledger records; the ledger says what those +/// records came to. +#[derive(Clone, Debug, Default)] +pub struct ConsumerCheckpointView<'a> { + /// Field 1: `consumer_id` + pub consumer_id: &'a str, + /// The source this consumer reads. Opaque here; a stream name, a subject, a + /// partition. + /// + /// Field 2: `source` + pub source: &'a str, + /// Position every usage fact below has a durable ledger record for. Advancing + /// this before writing those records would lose usage on a crash, which is the + /// one failure this ledger cannot detect afterwards: an unrecorded charge + /// leaves nothing behind to reconcile against. + /// + /// Field 3: `processed_watermark` + pub processed_watermark: u64, + /// Field 4: `processed_at` + pub processed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Records not in a terminal state. + /// + /// Field 5: `open_settlement_count` + pub open_settlement_count: u32, + /// Records specifically in UNKNOWN. Broken out because it is the number that + /// means money may have moved without anyone knowing, and burying it inside a + /// general open count is how it stops being looked at. + /// + /// Field 6: `unknown_settlement_count` + pub unknown_settlement_count: u32, + /// Source position of the oldest open settlement. Unset when nothing is open. + /// + /// Reported to bound a recovery scan, not to hold the watermark back. It is + /// the floor a scan can start from instead of re-reading everything the + /// consumer has ever processed. + /// + /// Field 7: `oldest_open_watermark` + pub oldest_open_watermark: ::core::option::Option, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ConsumerCheckpointView<'a> { + /**Whether required field `consumer_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_consumer_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `source` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_source(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `processed_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_processed_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `processed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_processed_at(&self) -> bool { + self.processed_at.is_set() + } + /**Whether required field `open_settlement_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_open_settlement_count(&self) -> bool { + self.__buffa_required_seen_0 & 8u64 != 0 + } + /**Whether required field `unknown_settlement_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_unknown_settlement_count(&self) -> bool { + self.__buffa_required_seen_0 & 16u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ConsumerCheckpointView<'a> { + type Owned = super::super::ConsumerCheckpoint; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.consumer_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.source = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.processed_watermark = ::buffa::types::decode_uint64(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.processed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.processed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.open_settlement_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 8u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.unknown_settlement_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 16u64; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.oldest_open_watermark = Some( + ::buffa::types::decode_uint64(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ConsumerCheckpoint { + consumer_id: self.consumer_id.to_string(), + source: self.source.to_string(), + processed_watermark: self.processed_watermark, + processed_at: match self.processed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + open_settlement_count: self.open_settlement_count, + unknown_settlement_count: self.unknown_settlement_count, + oldest_open_watermark: self.oldest_open_watermark, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ConsumerCheckpointView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.source) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if self.processed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.processed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.open_settlement_count) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.unknown_settlement_count) + as u64; + if let Some(v) = self.oldest_open_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + ::buffa::types::put_string_field(2u32, &self.source, buf); + ::buffa::types::put_uint64_field(3u32, self.processed_watermark, buf); + if self.processed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.processed_at.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.open_settlement_count, buf); + ::buffa::types::put_uint32_field(6u32, self.unknown_settlement_count, buf); + if let Some(v) = self.oldest_open_watermark { + ::buffa::types::put_uint64_field(7u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ConsumerCheckpointView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("consumerId", self.consumer_id)?; + } + { + __map.serialize_entry("source", self.source)?; + } + { + __map + .serialize_entry( + "processedWatermark", + &::buffa::json_helpers::ProtoJson(&self.processed_watermark), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.processed_at.as_option() { + __map.serialize_entry("processedAt", __v)?; + } + } + { + __map + .serialize_entry( + "openSettlementCount", + &::buffa::json_helpers::ProtoJson(&self.open_settlement_count), + )?; + } + { + __map + .serialize_entry( + "unknownSettlementCount", + &::buffa::json_helpers::ProtoJson(&self.unknown_settlement_count), + )?; + } + if let ::core::option::Option::Some(__v) = self.oldest_open_watermark { + __map + .serialize_entry( + "oldestOpenWatermark", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ConsumerCheckpointView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ConsumerCheckpoint"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint"; +} +::buffa::impl_default_view_instance!(ConsumerCheckpointView); +::buffa::impl_view_reborrow!(ConsumerCheckpointView); +/** Self-contained, `'static` owned view of a `ConsumerCheckpoint` message. + + Wraps [`::buffa::OwnedView`]`<`[`ConsumerCheckpointView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ConsumerCheckpointView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ConsumerCheckpointOwnedView( + ::buffa::OwnedView>, +); +impl ConsumerCheckpointOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsumerCheckpointOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsumerCheckpointOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ConsumerCheckpoint, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ConsumerCheckpointOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ConsumerCheckpointView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ConsumerCheckpointView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ConsumerCheckpoint { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `consumer_id` + #[must_use] + pub fn consumer_id(&self) -> &'_ str { + self.0.reborrow().consumer_id + } + /// The source this consumer reads. Opaque here; a stream name, a subject, a + /// partition. + /// + /// Field 2: `source` + #[must_use] + pub fn source(&self) -> &'_ str { + self.0.reborrow().source + } + /// Position every usage fact below has a durable ledger record for. Advancing + /// this before writing those records would lose usage on a crash, which is the + /// one failure this ledger cannot detect afterwards: an unrecorded charge + /// leaves nothing behind to reconcile against. + /// + /// Field 3: `processed_watermark` + #[must_use] + pub fn processed_watermark(&self) -> u64 { + self.0.reborrow().processed_watermark + } + /// Field 4: `processed_at` + #[must_use] + pub fn processed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().processed_at + } + /// Records not in a terminal state. + /// + /// Field 5: `open_settlement_count` + #[must_use] + pub fn open_settlement_count(&self) -> u32 { + self.0.reborrow().open_settlement_count + } + /// Records specifically in UNKNOWN. Broken out because it is the number that + /// means money may have moved without anyone knowing, and burying it inside a + /// general open count is how it stops being looked at. + /// + /// Field 6: `unknown_settlement_count` + #[must_use] + pub fn unknown_settlement_count(&self) -> u32 { + self.0.reborrow().unknown_settlement_count + } + /// Source position of the oldest open settlement. Unset when nothing is open. + /// + /// Reported to bound a recovery scan, not to hold the watermark back. It is + /// the floor a scan can start from instead of re-reading everything the + /// consumer has ever processed. + /// + /// Field 7: `oldest_open_watermark` + #[must_use] + pub fn oldest_open_watermark(&self) -> ::core::option::Option { + self.0.reborrow().oldest_open_watermark + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ConsumerCheckpointOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ConsumerCheckpointOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ConsumerCheckpointOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ConsumerCheckpointOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ConsumerCheckpoint { + type View<'a> = ConsumerCheckpointView<'a>; + type ViewHandle = ConsumerCheckpointOwnedView; +} +impl ::serde::Serialize for ConsumerCheckpointOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ScanOpenSettlementsRequest enumerates settlements that still need attention. +/// +/// Bounded on purpose. A recovery pass that scans the whole ledger gets slower +/// exactly as the system gets busier, so the pass meant to run during an +/// incident is the one that stops finishing during an incident. +#[derive(Clone, Debug, Default)] +pub struct ScanOpenSettlementsRequestView<'a> { + /// Field 1: `consumer_id` + pub consumer_id: &'a str, + /// Which states to return. Empty means every non-terminal state, which is the + /// ordinary recovery sweep. + /// + /// Field 2: `states` + pub states: ::buffa::RepeatedView< + 'a, + ::buffa::EnumValue, + >, + /// Only records untouched for at least this long. + /// + /// A settlement published a second ago and not yet acknowledged is not stuck, + /// it is in flight, and a recovery pass that republishes it is competing with + /// the attempt already running. Unset means no age filter, which is correct + /// for a report and wrong for an automated retry loop. + /// + /// Field 3: `idle_for` + pub idle_for: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'a>, + >, + /// Only records at or above this source position. Set from + /// `ConsumerCheckpoint.oldest_open_watermark` to make a sweep proportional to + /// what is actually open rather than to the ledger's size. + /// + /// Field 4: `from_watermark` + pub from_watermark: ::core::option::Option, + /// Field 5: `page_size` + pub page_size: u32, + /// Opaque continuation. Unset starts a new scan. + /// + /// Field 6: `page_token` + pub page_token: ::core::option::Option<&'a [u8]>, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ScanOpenSettlementsRequestView<'a> { + /**Whether required field `consumer_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_consumer_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `page_size` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_page_size(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ScanOpenSettlementsRequestView<'a> { + type Owned = super::super::ScanOpenSettlementsRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.consumer_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.idle_for.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.idle_for = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::DurationView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.from_watermark = Some(::buffa::types::decode_uint64(&mut cur)?); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.page_size = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 2u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let payload = ::buffa::types::borrow_bytes(&mut cur)?; + view.states.reserve(::buffa::encoding::count_varints(payload)); + let mut pcur: &[u8] = payload; + while !pcur.is_empty() { + view.states + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut pcur)?, + ), + ); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + view.states + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ), + ); + } else { + return Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ScanOpenSettlementsRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ScanOpenSettlementsRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ScanOpenSettlementsRequest { + consumer_id: self.consumer_id.to_string(), + states: self.states.to_vec(), + idle_for: match self.idle_for.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + from_watermark: self.from_watermark, + page_size: self.page_size, + page_token: self.page_token.map(|b| (b).to_vec()), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ScanOpenSettlementsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + if !self.states.is_empty() { + let payload: u64 = self + .states + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.idle_for.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.idle_for.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.from_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + if !self.states.is_empty() { + let payload: u64 = self + .states + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(2u32, payload, buf); + for v in &self.states { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.idle_for.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.idle_for.write_to(__cache, buf); + } + if let Some(v) = self.from_watermark { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + ::buffa::types::put_uint32_field(5u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(6u32, v, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ScanOpenSettlementsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("consumerId", self.consumer_id)?; + } + if !self.states.is_empty() { + __map + .serialize_entry( + "states", + &::buffa::json_helpers::EnumSeqJson(&self.states), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.idle_for.as_option() { + __map.serialize_entry("idleFor", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.from_watermark { + __map + .serialize_entry( + "fromWatermark", + &::buffa::json_helpers::ProtoJson(&__v), + )?; + } + { + __map + .serialize_entry( + "pageSize", + &::buffa::json_helpers::ProtoJson(&self.page_size), + )?; + } + if let ::core::option::Option::Some(__v) = self.page_token { + __map.serialize_entry("pageToken", &::buffa::json_helpers::BytesJson(__v))?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ScanOpenSettlementsRequestView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanOpenSettlementsRequest"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest"; +} +::buffa::impl_default_view_instance!(ScanOpenSettlementsRequestView); +::buffa::impl_view_reborrow!(ScanOpenSettlementsRequestView); +/** Self-contained, `'static` owned view of a `ScanOpenSettlementsRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ScanOpenSettlementsRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ScanOpenSettlementsRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ScanOpenSettlementsRequestOwnedView( + ::buffa::OwnedView>, +); +impl ScanOpenSettlementsRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ScanOpenSettlementsRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ScanOpenSettlementsRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ScanOpenSettlementsRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ScanOpenSettlementsRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `consumer_id` + #[must_use] + pub fn consumer_id(&self) -> &'_ str { + self.0.reborrow().consumer_id + } + /// Which states to return. Empty means every non-terminal state, which is the + /// ordinary recovery sweep. + /// + /// Field 2: `states` + #[must_use] + pub fn states( + &self, + ) -> &::buffa::RepeatedView<'_, ::buffa::EnumValue> { + &self.0.reborrow().states + } + /// Only records untouched for at least this long. + /// + /// A settlement published a second ago and not yet acknowledged is not stuck, + /// it is in flight, and a recovery pass that republishes it is competing with + /// the attempt already running. Unset means no age filter, which is correct + /// for a report and wrong for an automated retry loop. + /// + /// Field 3: `idle_for` + #[must_use] + pub fn idle_for( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::DurationView<'_>, + > { + &self.0.reborrow().idle_for + } + /// Only records at or above this source position. Set from + /// `ConsumerCheckpoint.oldest_open_watermark` to make a sweep proportional to + /// what is actually open rather than to the ledger's size. + /// + /// Field 4: `from_watermark` + #[must_use] + pub fn from_watermark(&self) -> ::core::option::Option { + self.0.reborrow().from_watermark + } + /// Field 5: `page_size` + #[must_use] + pub fn page_size(&self) -> u32 { + self.0.reborrow().page_size + } + /// Opaque continuation. Unset starts a new scan. + /// + /// Field 6: `page_token` + #[must_use] + pub fn page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().page_token + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ScanOpenSettlementsRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ScanOpenSettlementsRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ScanOpenSettlementsRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ScanOpenSettlementsRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ScanOpenSettlementsRequest { + type View<'a> = ScanOpenSettlementsRequestView<'a>; + type ViewHandle = ScanOpenSettlementsRequestOwnedView; +} +impl ::serde::Serialize for ScanOpenSettlementsRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ScanOpenSettlementsResponse is one page of unresolved settlements. +#[derive(Clone, Debug, Default)] +pub struct ScanOpenSettlementsResponseView<'a> { + /// Field 1: `records` + pub records: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::SettlementRecordView<'a>, + >, + /// Unset when this is the last page. Presence, and not an empty `records` + /// list, is the end signal. + /// + /// Field 2: `next_page_token` + pub next_page_token: ::core::option::Option<&'a [u8]>, + /// Field 3: `coverage` + pub coverage: ::buffa::MessageFieldView< + super::super::__buffa::view::ScanCoverageView<'a>, + >, +} +impl<'a> ScanOpenSettlementsResponseView<'a> { + /**Whether required field `coverage` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_coverage(&self) -> bool { + self.coverage.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ScanOpenSettlementsResponseView<'a> { + type Owned = super::super::ScanOpenSettlementsResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.next_page_token = Some(::buffa::types::borrow_bytes(&mut cur)?); + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.coverage.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.coverage = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + ctx.register_element_memory( + ::core::mem::size_of::< + super::super::__buffa::view::SettlementRecordView, + >(), + )?; + view.records + .push( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ScanOpenSettlementsResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ScanOpenSettlementsResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ScanOpenSettlementsResponse { + records: self + .records + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?, + next_page_token: self.next_page_token.map(|b| (b).to_vec()), + coverage: match self.coverage.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::ScanCoverage, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ScanOpenSettlementsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.records { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.coverage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.coverage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.records { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(2u32, v, buf); + } + if self.coverage.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.coverage.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ScanOpenSettlementsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.records.is_empty() { + __map.serialize_entry("records", &*self.records)?; + } + if let ::core::option::Option::Some(__v) = self.next_page_token { + __map + .serialize_entry( + "nextPageToken", + &::buffa::json_helpers::BytesJson(__v), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.coverage.as_option() { + __map.serialize_entry("coverage", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ScanOpenSettlementsResponseView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanOpenSettlementsResponse"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse"; +} +::buffa::impl_default_view_instance!(ScanOpenSettlementsResponseView); +::buffa::impl_view_reborrow!(ScanOpenSettlementsResponseView); +/** Self-contained, `'static` owned view of a `ScanOpenSettlementsResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`ScanOpenSettlementsResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ScanOpenSettlementsResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ScanOpenSettlementsResponseOwnedView( + ::buffa::OwnedView>, +); +impl ScanOpenSettlementsResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ScanOpenSettlementsResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanOpenSettlementsResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ScanOpenSettlementsResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ScanOpenSettlementsResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ScanOpenSettlementsResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `records` + #[must_use] + pub fn records( + &self, + ) -> &::buffa::RepeatedView< + '_, + super::super::__buffa::view::SettlementRecordView<'_>, + > { + &self.0.reborrow().records + } + /// Unset when this is the last page. Presence, and not an empty `records` + /// list, is the end signal. + /// + /// Field 2: `next_page_token` + #[must_use] + pub fn next_page_token(&self) -> ::core::option::Option<&'_ [u8]> { + self.0.reborrow().next_page_token + } + /// Field 3: `coverage` + #[must_use] + pub fn coverage( + &self, + ) -> &::buffa::MessageFieldView> { + &self.0.reborrow().coverage + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ScanOpenSettlementsResponseOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + ScanOpenSettlementsResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ScanOpenSettlementsResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ScanOpenSettlementsResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ScanOpenSettlementsResponse { + type View<'a> = ScanOpenSettlementsResponseView<'a>; + type ViewHandle = ScanOpenSettlementsResponseOwnedView; +} +impl ::serde::Serialize for ScanOpenSettlementsResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ScanCoverage is what the scan did not look at. +/// +/// Always present, including on a scan that covered everything. An operator +/// reading an empty page needs to know whether that means nothing is open or +/// the scan ran out of budget, and those two look identical without this. +#[derive(Clone, Debug, Default)] +pub struct ScanCoverageView<'a> { + /// Field 1: `exhaustive` + pub exhaustive: bool, + /// Source position the scan covered through. + /// + /// Field 2: `scanned_through_watermark` + pub scanned_through_watermark: u64, + /// Records matching the filter that a fault made unreadable. Non-zero means + /// unresolved settlements exist that this scan cannot name, so the sweep must + /// not be treated as having cleared anything. + /// + /// Field 3: `unreadable_count` + pub unreadable_count: u32, + /// Field 4: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ScanCoverageView<'a> { + /**Whether required field `exhaustive` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_exhaustive(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `scanned_through_watermark` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_scanned_through_watermark(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } + /**Whether required field `unreadable_count` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_unreadable_count(&self) -> bool { + self.__buffa_required_seen_0 & 4u64 != 0 + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ScanCoverageView<'a> { + type Owned = super::super::ScanCoverage; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.exhaustive = ::buffa::types::decode_bool(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.scanned_through_watermark = ::buffa::types::decode_uint64( + &mut cur, + )?; + view.__buffa_required_seen_0 |= 2u64; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.unreadable_count = ::buffa::types::decode_uint32(&mut cur)?; + view.__buffa_required_seen_0 |= 4u64; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ScanCoverage { + exhaustive: self.exhaustive, + scanned_through_watermark: self.scanned_through_watermark, + unreadable_count: self.unreadable_count, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ScanCoverageView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.scanned_through_watermark) + as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unreadable_count) as u64; + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_bool_field(1u32, self.exhaustive, buf); + ::buffa::types::put_uint64_field(2u32, self.scanned_through_watermark, buf); + ::buffa::types::put_uint32_field(3u32, self.unreadable_count, buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ScanCoverageView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("exhaustive", &self.exhaustive)?; + } + { + __map + .serialize_entry( + "scannedThroughWatermark", + &::buffa::json_helpers::ProtoJson(&self.scanned_through_watermark), + )?; + } + { + __map + .serialize_entry( + "unreadableCount", + &::buffa::json_helpers::ProtoJson(&self.unreadable_count), + )?; + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ScanCoverageView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanCoverage"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanCoverage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanCoverage"; +} +::buffa::impl_default_view_instance!(ScanCoverageView); +::buffa::impl_view_reborrow!(ScanCoverageView); +/** Self-contained, `'static` owned view of a `ScanCoverage` message. + + Wraps [`::buffa::OwnedView`]`<`[`ScanCoverageView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ScanCoverageView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ScanCoverageOwnedView(::buffa::OwnedView>); +impl ScanCoverageOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanCoverageOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanCoverageOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ScanCoverage, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ScanCoverageOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ScanCoverageView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ScanCoverageView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ScanCoverage { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `exhaustive` + #[must_use] + pub fn exhaustive(&self) -> bool { + self.0.reborrow().exhaustive + } + /// Source position the scan covered through. + /// + /// Field 2: `scanned_through_watermark` + #[must_use] + pub fn scanned_through_watermark(&self) -> u64 { + self.0.reborrow().scanned_through_watermark + } + /// Records matching the filter that a fault made unreadable. Non-zero means + /// unresolved settlements exist that this scan cannot name, so the sweep must + /// not be treated as having cleared anything. + /// + /// Field 3: `unreadable_count` + #[must_use] + pub fn unreadable_count(&self) -> u32 { + self.0.reborrow().unreadable_count + } + /// Field 4: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ScanCoverageOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ScanCoverageOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ScanCoverageOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ScanCoverageOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ScanCoverage { + type View<'a> = ScanCoverageView<'a>; + type ViewHandle = ScanCoverageOwnedView; +} +impl ::serde::Serialize for ScanCoverageOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReconcileSettlementRequest asks the provider what actually happened to a +/// settlement whose outcome was never observed. +/// +/// A query, not a retry. It exists so a consumer facing UNKNOWN has a move other +/// than publishing again and hoping the idempotency key holds, and there is no +/// field on it that could cause a charge. +#[derive(Clone, Debug, Default)] +pub struct ReconcileSettlementRequestView<'a> { + /// Field 1: `consumer_id` + pub consumer_id: &'a str, + /// Field 2: `settlement_id` + pub settlement_id: &'a str, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileSettlementRequestView<'a> { + /**Whether required field `consumer_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_consumer_id(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `settlement_id` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_settlement_id(&self) -> bool { + self.__buffa_required_seen_0 & 2u64 != 0 + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileSettlementRequestView<'a> { + type Owned = super::super::ReconcileSettlementRequest; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.consumer_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + view.settlement_id = ::buffa::types::borrow_str(&mut cur)?; + view.__buffa_required_seen_0 |= 2u64; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileSettlementRequest, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileSettlementRequest, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileSettlementRequest { + consumer_id: self.consumer_id.to_string(), + settlement_id: self.settlement_id.to_string(), + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileSettlementRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.settlement_id) as u64; + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + ::buffa::types::put_string_field(2u32, &self.settlement_id, buf); + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileSettlementRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("consumerId", self.consumer_id)?; + } + { + __map.serialize_entry("settlementId", self.settlement_id)?; + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileSettlementRequestView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ReconcileSettlementRequest"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest"; +} +::buffa::impl_default_view_instance!(ReconcileSettlementRequestView); +::buffa::impl_view_reborrow!(ReconcileSettlementRequestView); +/** Self-contained, `'static` owned view of a `ReconcileSettlementRequest` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileSettlementRequestView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileSettlementRequestView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileSettlementRequestOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileSettlementRequestOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementRequestOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementRequestOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileSettlementRequest, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementRequestOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileSettlementRequestView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileSettlementRequestView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileSettlementRequest { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `consumer_id` + #[must_use] + pub fn consumer_id(&self) -> &'_ str { + self.0.reborrow().consumer_id + } + /// Field 2: `settlement_id` + #[must_use] + pub fn settlement_id(&self) -> &'_ str { + self.0.reborrow().settlement_id + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileSettlementRequestOwnedView { + fn from(inner: ::buffa::OwnedView>) -> Self { + ReconcileSettlementRequestOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileSettlementRequestOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileSettlementRequestOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileSettlementRequest { + type View<'a> = ReconcileSettlementRequestView<'a>; + type ViewHandle = ReconcileSettlementRequestOwnedView; +} +impl ::serde::Serialize for ReconcileSettlementRequestOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} +/// ReconcileSettlementResponse is what the provider says it knows. +#[derive(Clone, Debug, Default)] +pub struct ReconcileSettlementResponseView<'a> { + /// Field 1: `outcome` + pub outcome: ::buffa::EnumValue, + /// The updated ledger record, so a caller never has to reconstruct the new + /// state from the outcome and hope its transition table matches the server's. + /// + /// Field 2: `record` + pub record: ::buffa::MessageFieldView< + super::super::__buffa::view::SettlementRecordView<'a>, + >, + /// Field 3: `observed_at` + pub observed_at: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + #[doc(hidden)] + pub __buffa_required_seen_0: u64, +} +impl<'a> ReconcileSettlementResponseView<'a> { + /**Whether required field `outcome` was present on the wire. + +Distinguishes a field that was absent from one explicitly encoded with its default value (required scalar fields are stored as bare, non-`Option` types, so the value alone cannot tell the two apart). Presence is recorded only by the wire decoder: a default or hand-built view reports `false`. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_outcome(&self) -> bool { + self.__buffa_required_seen_0 & 1u64 != 0 + } + /**Whether required field `record` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_record(&self) -> bool { + self.record.is_set() + } + /**Whether required field `observed_at` is set. + +Mirrors `is_set()` on the field: `true` after decoding a message where the field was present on the wire, and `true` on a hand-built view whose field is populated. Encoding is unaffected — required fields are always written.*/ + #[must_use] + #[inline] + pub const fn has_observed_at(&self) -> bool { + self.observed_at.is_set() + } +} +impl<'a> ::buffa::MessageView<'a> for ReconcileSettlementResponseView<'a> { + type Owned = super::super::ReconcileSettlementResponse; + fn decode_view(buf: &'a [u8]) -> ::core::result::Result { + let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT); + ::decode_view_ctx( + buf, + ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit), + ) + } + fn decode_view_with_ctx( + buf: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result { + ::decode_view_ctx(buf, ctx) + } + #[inline] + fn merge_view_field( + &mut self, + tag: ::buffa::encoding::Tag, + cur: &'a [u8], + _before_tag: &'a [u8], + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> { + let _ = ctx; + #[allow(unused_variables)] + let view = self; + let mut cur = cur; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + view.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + view.__buffa_required_seen_0 |= 1u64; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.record.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.record = ::buffa::MessageFieldView::set( + ::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let __sub_ctx = ctx.descend()?; + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.observed_at.as_mut() { + Some(existing) => { + ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)? + } + None => { + view.observed_at = ::buffa::MessageFieldView::set( + <::buffa_types::google::protobuf::__buffa::view::TimestampView as ::buffa::MessageView>::decode_view_ctx( + sub, + __sub_ctx, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?; + } + } + ::core::result::Result::Ok(cur) + } + fn to_owned_message( + &self, + ) -> ::core::result::Result< + super::super::ReconcileSettlementResponse, + ::buffa::DecodeError, + > { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> ::core::result::Result< + super::super::ReconcileSettlementResponse, + ::buffa::DecodeError, + > { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + ::core::result::Result::Ok(super::super::ReconcileSettlementResponse { + outcome: self.outcome, + record: match self.record.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SettlementRecord, + ::buffa::Inline, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + observed_at: match self.observed_at.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >::some(v.to_owned_from_source(__buffa_src)?) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + }) + } +} +impl<'a> ::buffa::ViewEncode<'a> for ReconcileSettlementResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.outcome.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } +} +/// Serializes this view as protobuf JSON. +/// +/// Implicit-presence fields with default values are omitted, `required` +/// fields are always emitted, explicit-presence (`optional`) fields are +/// emitted only when set, bytes fields are base64-encoded, and enum +/// values are their proto name strings. +/// +/// This impl uses `serialize_map(None)` because the number of emitted +/// fields depends on default-omission rules; serializers that require +/// known map lengths (e.g. `bincode`) will return a runtime error. +/// Use the owned message type for those formats. +impl<'__a> ::serde::Serialize for ReconcileSettlementResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + __map.serialize_entry("outcome", &self.outcome)?; + } + { + if let ::core::option::Option::Some(__v) = self.record.as_option() { + __map.serialize_entry("record", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.observed_at.as_option() { + __map.serialize_entry("observedAt", __v)?; + } + } + __map.end() + } +} +impl<'a> ::buffa::MessageName for ReconcileSettlementResponseView<'a> { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ReconcileSettlementResponse"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse"; +} +::buffa::impl_default_view_instance!(ReconcileSettlementResponseView); +::buffa::impl_view_reborrow!(ReconcileSettlementResponseView); +/** Self-contained, `'static` owned view of a `ReconcileSettlementResponse` message. + + Wraps [`::buffa::OwnedView`]`<`[`ReconcileSettlementResponseView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required. + + Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ReconcileSettlementResponseView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/ +#[derive(Clone, Debug)] +pub struct ReconcileSettlementResponseOwnedView( + ::buffa::OwnedView>, +); +impl ReconcileSettlementResponseOwnedView { + /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer. + /// + /// The view borrows directly from the buffer's data; the buffer is + /// retained inside the returned handle. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer contains invalid + /// protobuf data. + pub fn decode( + bytes: ::buffa::bytes::Bytes, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementResponseOwnedView(::buffa::OwnedView::decode(bytes)?), + ) + } + /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit, + /// max message size). + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError`] if the buffer is invalid or + /// exceeds the configured limits. + pub fn decode_with_options( + bytes: ::buffa::bytes::Bytes, + opts: &::buffa::DecodeOptions, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementResponseOwnedView( + ::buffa::OwnedView::decode_with_options(bytes, opts)?, + ), + ) + } + /// Build from an owned message via an encode → decode round-trip. + /// + /// # Errors + /// + /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the + /// message's encoded size exceeds the 2 GiB protobuf limit, or + /// another [`::buffa::DecodeError`] if the re-encoded bytes are + /// somehow invalid (should not happen for well-formed messages). + pub fn from_owned( + msg: &super::super::ReconcileSettlementResponse, + ) -> ::core::result::Result { + ::core::result::Result::Ok( + ReconcileSettlementResponseOwnedView(::buffa::OwnedView::from_owned(msg)?), + ) + } + /// Borrow the full [`ReconcileSettlementResponseView`] with its lifetime tied to `&self`. + #[must_use] + pub fn view(&self) -> &ReconcileSettlementResponseView<'_> { + self.0.reborrow() + } + /// Convert to the owned message type. + /// + /// Infallible: this type's constructors wire-decode their + /// buffer, and a view produced by wire decoding always + /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`], + /// whose contract also governs handles converted from a raw + /// [`::buffa::OwnedView`]. + #[must_use] + pub fn to_owned_message(&self) -> super::super::ReconcileSettlementResponse { + self.0.to_owned_message() + } + /// The underlying bytes buffer. + #[must_use] + pub fn bytes(&self) -> &::buffa::bytes::Bytes { + self.0.bytes() + } + /// Consume the handle, returning the underlying bytes buffer. + #[must_use] + pub fn into_bytes(self) -> ::buffa::bytes::Bytes { + self.0.into_bytes() + } + /// Field 1: `outcome` + #[must_use] + pub fn outcome(&self) -> ::buffa::EnumValue { + self.0.reborrow().outcome + } + /// The updated ledger record, so a caller never has to reconstruct the new + /// state from the outcome and hope its transition table matches the server's. + /// + /// Field 2: `record` + #[must_use] + pub fn record( + &self, + ) -> &::buffa::MessageFieldView< + super::super::__buffa::view::SettlementRecordView<'_>, + > { + &self.0.reborrow().record + } + /// Field 3: `observed_at` + #[must_use] + pub fn observed_at( + &self, + ) -> &::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>, + > { + &self.0.reborrow().observed_at + } +} +impl ::core::convert::From<::buffa::OwnedView>> +for ReconcileSettlementResponseOwnedView { + fn from( + inner: ::buffa::OwnedView>, + ) -> Self { + ReconcileSettlementResponseOwnedView(inner) + } +} +impl ::core::convert::From +for ::buffa::OwnedView> { + fn from(wrapper: ReconcileSettlementResponseOwnedView) -> Self { + wrapper.0 + } +} +impl ::core::convert::AsRef<::buffa::OwnedView>> +for ReconcileSettlementResponseOwnedView { + fn as_ref(&self) -> &::buffa::OwnedView> { + &self.0 + } +} +impl ::buffa::HasMessageView for super::super::ReconcileSettlementResponse { + type View<'a> = ReconcileSettlementResponseView<'a>; + type ViewHandle = ReconcileSettlementResponseOwnedView; +} +impl ::serde::Serialize for ReconcileSettlementResponseOwnedView { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::serde::Serialize::serialize(&self.0, __s) + } +} diff --git a/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.rs b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.rs new file mode 100644 index 0000000000..aed7ec2639 --- /dev/null +++ b/rsworkspace/crates/platform/trogonai-proto/src/gen/trogonai.usage.settlement.v1alpha1.recovery.rs @@ -0,0 +1,1537 @@ +// @generated by buffa-codegen. DO NOT EDIT. +// source: trogonai/usage/settlement/v1alpha1/recovery.proto + +/// ReconciliationOutcome is what asking the provider established. +/// +/// The zero value keeps the settlement unresolved, so a reconciliation that +/// returns a variant the caller does not understand leaves the record needing +/// attention instead of closing it. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum ReconciliationOutcome { + /// Unknown result. Nothing changes; the record stays unresolved. + RECONCILIATION_OUTCOME_UNSPECIFIED = 0i32, + /// The provider has the charge. The record becomes SETTLED. + RECONCILIATION_OUTCOME_CHARGE_FOUND = 1i32, + /// The provider has no charge under this idempotency key and confirms it + /// never processed one. The record becomes INTENDED and may be published. + RECONCILIATION_OUTCOME_CHARGE_ABSENT = 2i32, + /// The provider refused, and says so now. The record becomes REJECTED. + RECONCILIATION_OUTCOME_CHARGE_REFUSED = 3i32, + /// The provider cannot say, usually because the key is older than its + /// retention for idempotency records. + /// + /// Reported rather than folded into ABSENT, because they differ on the only + /// question that matters: absent means republishing is safe, and this means + /// the provider has forgotten the key that was making it safe. This is what + /// opens INCIDENT_KIND_UNKNOWN_OUTCOME_EXPIRED. + RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY = 4i32, + /// The provider could not be reached. Says nothing about the charge; the + /// record stays UNKNOWN and the reconciliation can be tried again. + RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE = 5i32, +} +impl ReconciliationOutcome { + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_UNSPECIFIED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const Unspecified: Self = Self::RECONCILIATION_OUTCOME_UNSPECIFIED; + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_CHARGE_FOUND`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChargeFound: Self = Self::RECONCILIATION_OUTCOME_CHARGE_FOUND; + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChargeAbsent: Self = Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT; + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ChargeRefused: Self = Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED; + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProviderCannotSay: Self = Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY; + ///Idiomatic alias for [`Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE`]; `Debug` prints the variant name. + #[allow(non_upper_case_globals)] + pub const ProviderUnreachable: Self = Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE; +} +impl ::core::default::Default for ReconciliationOutcome { + fn default() -> Self { + Self::RECONCILIATION_OUTCOME_UNSPECIFIED + } +} +impl ::serde::Serialize for ReconciliationOutcome { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for ReconciliationOutcome { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = ReconciliationOutcome; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!( + "a string, integer, or null for ", + stringify!(ReconciliationOutcome) + ), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconciliationOutcome { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for ReconciliationOutcome { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_UNSPECIFIED) + } + 1i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_FOUND) + } + 2i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT) + } + 3i32 => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED) + } + 4i32 => { + ::core::option::Option::Some( + Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY, + ) + } + 5i32 => { + ::core::option::Option::Some( + Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE, + ) + } + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::RECONCILIATION_OUTCOME_UNSPECIFIED => { + "RECONCILIATION_OUTCOME_UNSPECIFIED" + } + Self::RECONCILIATION_OUTCOME_CHARGE_FOUND => { + "RECONCILIATION_OUTCOME_CHARGE_FOUND" + } + Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT => { + "RECONCILIATION_OUTCOME_CHARGE_ABSENT" + } + Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED => { + "RECONCILIATION_OUTCOME_CHARGE_REFUSED" + } + Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY => { + "RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY" + } + Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE => { + "RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE" + } + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "RECONCILIATION_OUTCOME_UNSPECIFIED" => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_UNSPECIFIED) + } + "RECONCILIATION_OUTCOME_CHARGE_FOUND" => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_FOUND) + } + "RECONCILIATION_OUTCOME_CHARGE_ABSENT" => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT) + } + "RECONCILIATION_OUTCOME_CHARGE_REFUSED" => { + ::core::option::Option::Some(Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED) + } + "RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY" => { + ::core::option::Option::Some( + Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY, + ) + } + "RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE" => { + ::core::option::Option::Some( + Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE, + ) + } + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::RECONCILIATION_OUTCOME_UNSPECIFIED, + Self::RECONCILIATION_OUTCOME_CHARGE_FOUND, + Self::RECONCILIATION_OUTCOME_CHARGE_ABSENT, + Self::RECONCILIATION_OUTCOME_CHARGE_REFUSED, + Self::RECONCILIATION_OUTCOME_PROVIDER_CANNOT_SAY, + Self::RECONCILIATION_OUTCOME_PROVIDER_UNREACHABLE, + ] + } +} +/// Recovery for a billing consumer: where it got to, and what it left open. +/// +/// ConsumerCheckpoint is how far a billing consumer has read its source. +/// +/// Consumption position and settlement state are tracked separately, and that +/// separation is deliberate. If the watermark could not advance past an +/// unresolved settlement, one charge stuck behind a provider outage would stop +/// billing for everything after it, and the outage would turn into a backlog +/// measured in whatever the busiest tenant produced meanwhile. The watermark +/// says what has been turned into ledger records; the ledger says what those +/// records came to. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ConsumerCheckpoint { + /// Field 1: `consumer_id` + #[serde( + rename = "consumerId", + alias = "consumer_id", + with = "::buffa::json_helpers::proto_string" + )] + pub consumer_id: ::buffa::alloc::string::String, + /// The source this consumer reads. Opaque here; a stream name, a subject, a + /// partition. + /// + /// Field 2: `source` + #[serde(rename = "source", with = "::buffa::json_helpers::proto_string")] + pub source: ::buffa::alloc::string::String, + /// Position every usage fact below has a durable ledger record for. Advancing + /// this before writing those records would lose usage on a crash, which is the + /// one failure this ledger cannot detect afterwards: an unrecorded charge + /// leaves nothing behind to reconcile against. + /// + /// Field 3: `processed_watermark` + #[serde( + rename = "processedWatermark", + alias = "processed_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub processed_watermark: u64, + /// Field 4: `processed_at` + #[serde(rename = "processedAt", alias = "processed_at")] + pub processed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, + /// Records not in a terminal state. + /// + /// Field 5: `open_settlement_count` + #[serde( + rename = "openSettlementCount", + alias = "open_settlement_count", + with = "::buffa::json_helpers::uint32" + )] + pub open_settlement_count: u32, + /// Records specifically in UNKNOWN. Broken out because it is the number that + /// means money may have moved without anyone knowing, and burying it inside a + /// general open count is how it stops being looked at. + /// + /// Field 6: `unknown_settlement_count` + #[serde( + rename = "unknownSettlementCount", + alias = "unknown_settlement_count", + with = "::buffa::json_helpers::uint32" + )] + pub unknown_settlement_count: u32, + /// Source position of the oldest open settlement. Unset when nothing is open. + /// + /// Reported to bound a recovery scan, not to hold the watermark back. It is + /// the floor a scan can start from instead of re-reading everything the + /// consumer has ever processed. + /// + /// Field 7: `oldest_open_watermark` + #[serde( + rename = "oldestOpenWatermark", + alias = "oldest_open_watermark", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub oldest_open_watermark: ::core::option::Option, +} +impl ::core::fmt::Debug for ConsumerCheckpoint { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConsumerCheckpoint") + .field("consumer_id", &self.consumer_id) + .field("source", &self.source) + .field("processed_watermark", &self.processed_watermark) + .field("processed_at", &self.processed_at) + .field("open_settlement_count", &self.open_settlement_count) + .field("unknown_settlement_count", &self.unknown_settlement_count) + .field("oldest_open_watermark", &self.oldest_open_watermark) + .finish() + } +} +impl ConsumerCheckpoint { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint"; +} +impl ConsumerCheckpoint { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::oldest_open_watermark`] to `Some(value)`, consuming and returning `self`. + pub fn with_oldest_open_watermark(mut self, value: u64) -> Self { + self.oldest_open_watermark = Some(value); + self + } +} +::buffa::impl_default_instance!(ConsumerCheckpoint); +impl ::buffa::MessageName for ConsumerCheckpoint { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ConsumerCheckpoint"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint"; +} +impl ::buffa::Message for ConsumerCheckpoint { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.source) as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.processed_watermark) as u64; + if self.processed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.processed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.open_settlement_count) as u64; + size + += 1u64 + + ::buffa::types::uint32_encoded_len(self.unknown_settlement_count) + as u64; + if let Some(v) = self.oldest_open_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + ::buffa::types::put_string_field(2u32, &self.source, buf); + ::buffa::types::put_uint64_field(3u32, self.processed_watermark, buf); + if self.processed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.processed_at.write_to(__cache, buf); + } + ::buffa::types::put_uint32_field(5u32, self.open_settlement_count, buf); + ::buffa::types::put_uint32_field(6u32, self.unknown_settlement_count, buf); + if let Some(v) = self.oldest_open_watermark { + ::buffa::types::put_uint64_field(7u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.consumer_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.source, buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.processed_watermark = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.processed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.open_settlement_count = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.unknown_settlement_count = ::buffa::types::decode_uint32(buf)?; + } + 7u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.oldest_open_watermark = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.consumer_id.clear(); + self.source.clear(); + self.processed_watermark = 0u64; + self.processed_at = ::buffa::MessageField::none(); + self.open_settlement_count = 0u32; + self.unknown_settlement_count = 0u32; + self.oldest_open_watermark = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConsumerCheckpoint { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONSUMER_CHECKPOINT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ConsumerCheckpoint", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ScanOpenSettlementsRequest enumerates settlements that still need attention. +/// +/// Bounded on purpose. A recovery pass that scans the whole ledger gets slower +/// exactly as the system gets busier, so the pass meant to run during an +/// incident is the one that stops finishing during an incident. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ScanOpenSettlementsRequest { + /// Field 1: `consumer_id` + #[serde( + rename = "consumerId", + alias = "consumer_id", + with = "::buffa::json_helpers::proto_string" + )] + pub consumer_id: ::buffa::alloc::string::String, + /// Which states to return. Empty means every non-terminal state, which is the + /// ordinary recovery sweep. + /// + /// Field 2: `states` + #[serde( + rename = "states", + with = "::buffa::json_helpers::repeated_enum", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec" + )] + pub states: ::buffa::alloc::vec::Vec<::buffa::EnumValue>, + /// Only records untouched for at least this long. + /// + /// A settlement published a second ago and not yet acknowledged is not stuck, + /// it is in flight, and a recovery pass that republishes it is competing with + /// the attempt already running. Unset means no age filter, which is correct + /// for a report and wrong for an automated retry loop. + /// + /// Field 3: `idle_for` + #[serde( + rename = "idleFor", + alias = "idle_for", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub idle_for: ::buffa::MessageField< + ::buffa_types::google::protobuf::Duration, + ::buffa::Inline<::buffa_types::google::protobuf::Duration>, + >, + /// Only records at or above this source position. Set from + /// `ConsumerCheckpoint.oldest_open_watermark` to make a sweep proportional to + /// what is actually open rather than to the ledger's size. + /// + /// Field 4: `from_watermark` + #[serde( + rename = "fromWatermark", + alias = "from_watermark", + with = "::buffa::json_helpers::opt_uint64", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub from_watermark: ::core::option::Option, + /// Field 5: `page_size` + #[serde( + rename = "pageSize", + alias = "page_size", + with = "::buffa::json_helpers::uint32" + )] + pub page_size: u32, + /// Opaque continuation. Unset starts a new scan. + /// + /// Field 6: `page_token` + #[serde( + rename = "pageToken", + alias = "page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, +} +impl ::core::fmt::Debug for ScanOpenSettlementsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ScanOpenSettlementsRequest") + .field("consumer_id", &self.consumer_id) + .field("states", &self.states) + .field("idle_for", &self.idle_for) + .field("from_watermark", &self.from_watermark) + .field("page_size", &self.page_size) + .field("page_token", &self.page_token) + .finish() + } +} +impl ScanOpenSettlementsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest"; +} +impl ScanOpenSettlementsRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::from_watermark`] to `Some(value)`, consuming and returning `self`. + pub fn with_from_watermark(mut self, value: u64) -> Self { + self.from_watermark = Some(value); + self + } + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ScanOpenSettlementsRequest); +impl ::buffa::MessageName for ScanOpenSettlementsRequest { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanOpenSettlementsRequest"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest"; +} +impl ::buffa::Message for ScanOpenSettlementsRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + if !self.states.is_empty() { + let payload: u64 = self + .states + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload; + } + if self.idle_for.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.idle_for.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(v) = self.from_watermark { + size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64; + } + size += 1u64 + ::buffa::types::uint32_encoded_len(self.page_size) as u64; + if let Some(ref v) = self.page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + if !self.states.is_empty() { + let payload: u64 = self + .states + .iter() + .map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64) + .sum::(); + ::buffa::types::put_len_delimited_header(2u32, payload, buf); + for v in &self.states { + ::buffa::types::encode_int32(v.to_i32(), buf); + } + } + if self.idle_for.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.idle_for.write_to(__cache, buf); + } + if let Some(v) = self.from_watermark { + ::buffa::types::put_uint64_field(4u32, v, buf); + } + ::buffa::types::put_uint32_field(5u32, self.page_size, buf); + if let Some(ref v) = self.page_token { + ::buffa::types::put_shared_bytes_field(6u32, v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.consumer_id, buf)?; + } + 2u32 => { + if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = usize::try_from(len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + self.states.reserve(len); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.states + .push( + ::buffa::EnumValue::from( + ::buffa::types::decode_int32_packed(&mut limited)?, + ), + ); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint { + self.states + .push( + ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?), + ); + } else { + return ::core::result::Result::Err( + ::buffa::encoding::wire_type_mismatch( + tag, + ::buffa::encoding::WireType::LengthDelimited, + ), + ); + } + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.idle_for.get_or_insert_default(), + buf, + ctx, + )?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.from_watermark = ::core::option::Option::Some( + ::buffa::types::decode_uint64(buf)?, + ); + } + 5u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.page_size = ::buffa::types::decode_uint32(buf)?; + } + 6u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self.page_token.get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.consumer_id.clear(); + self.states.clear(); + self.idle_for = ::buffa::MessageField::none(); + self.from_watermark = ::core::option::Option::None; + self.page_size = 0u32; + self.page_token = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for ScanOpenSettlementsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SCAN_OPEN_SETTLEMENTS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ScanOpenSettlementsResponse is one page of unresolved settlements. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ScanOpenSettlementsResponse { + /// Field 1: `records` + #[serde( + rename = "records", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub records: ::buffa::alloc::vec::Vec, + /// Unset when this is the last page. Presence, and not an empty `records` + /// list, is the end signal. + /// + /// Field 2: `next_page_token` + #[serde( + rename = "nextPageToken", + alias = "next_page_token", + with = "::buffa::json_helpers::opt_bytes", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub next_page_token: ::core::option::Option<::buffa::alloc::vec::Vec>, + /// Field 3: `coverage` + #[serde(rename = "coverage")] + pub coverage: ::buffa::MessageField>, +} +impl ::core::fmt::Debug for ScanOpenSettlementsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ScanOpenSettlementsResponse") + .field("records", &self.records) + .field("next_page_token", &self.next_page_token) + .field("coverage", &self.coverage) + .finish() + } +} +impl ScanOpenSettlementsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse"; +} +impl ScanOpenSettlementsResponse { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::next_page_token`] to `Some(value)`, consuming and returning `self`. + pub fn with_next_page_token( + mut self, + value: impl Into<::buffa::alloc::vec::Vec>, + ) -> Self { + self.next_page_token = Some(value.into()); + self + } +} +::buffa::impl_default_instance!(ScanOpenSettlementsResponse); +impl ::buffa::MessageName for ScanOpenSettlementsResponse { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanOpenSettlementsResponse"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse"; +} +impl ::buffa::Message for ScanOpenSettlementsResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + for v in &self.records { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if let Some(ref v) = self.next_page_token { + size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64; + } + if self.coverage.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.coverage.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.records { + ::buffa::types::put_len_delimited_header( + 1u32, + u64::from(__cache.consume_next()), + buf, + ); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.next_page_token { + ::buffa::types::put_shared_bytes_field(2u32, v, buf); + } + if self.coverage.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.coverage.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + let mut elem = ::core::default::Default::default(); + ctx.register_element_memory( + ::buffa::__private::element_footprint(&elem), + )?; + ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?; + self.records.push(elem); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_bytes( + self + .next_page_token + .get_or_insert_with(::buffa::alloc::vec::Vec::new), + buf, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.coverage.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.records.clear(); + self.next_page_token = ::core::option::Option::None; + self.coverage = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ScanOpenSettlementsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SCAN_OPEN_SETTLEMENTS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanOpenSettlementsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ScanCoverage is what the scan did not look at. +/// +/// Always present, including on a scan that covered everything. An operator +/// reading an empty page needs to know whether that means nothing is open or +/// the scan ran out of budget, and those two look identical without this. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ScanCoverage { + /// Field 1: `exhaustive` + #[serde(rename = "exhaustive", with = "::buffa::json_helpers::proto_bool")] + pub exhaustive: bool, + /// Source position the scan covered through. + /// + /// Field 2: `scanned_through_watermark` + #[serde( + rename = "scannedThroughWatermark", + alias = "scanned_through_watermark", + with = "::buffa::json_helpers::uint64" + )] + pub scanned_through_watermark: u64, + /// Records matching the filter that a fault made unreadable. Non-zero means + /// unresolved settlements exist that this scan cannot name, so the sweep must + /// not be treated as having cleared anything. + /// + /// Field 3: `unreadable_count` + #[serde( + rename = "unreadableCount", + alias = "unreadable_count", + with = "::buffa::json_helpers::uint32" + )] + pub unreadable_count: u32, + /// Field 4: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ScanCoverage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ScanCoverage") + .field("exhaustive", &self.exhaustive) + .field("scanned_through_watermark", &self.scanned_through_watermark) + .field("unreadable_count", &self.unreadable_count) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl ScanCoverage { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanCoverage"; +} +::buffa::impl_default_instance!(ScanCoverage); +impl ::buffa::MessageName for ScanCoverage { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ScanCoverage"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ScanCoverage"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanCoverage"; +} +impl ::buffa::Message for ScanCoverage { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64; + size + += 1u64 + + ::buffa::types::uint64_encoded_len(self.scanned_through_watermark) + as u64; + size += 1u64 + ::buffa::types::uint32_encoded_len(self.unreadable_count) as u64; + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_bool_field(1u32, self.exhaustive, buf); + ::buffa::types::put_uint64_field(2u32, self.scanned_through_watermark, buf); + ::buffa::types::put_uint32_field(3u32, self.unreadable_count, buf); + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 4u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.exhaustive = ::buffa::types::decode_bool(buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.scanned_through_watermark = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.unreadable_count = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.exhaustive = false; + self.scanned_through_watermark = 0u64; + self.unreadable_count = 0u32; + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ScanCoverage { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SCAN_COVERAGE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ScanCoverage", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReconcileSettlementRequest asks the provider what actually happened to a +/// settlement whose outcome was never observed. +/// +/// A query, not a retry. It exists so a consumer facing UNKNOWN has a move other +/// than publishing again and hoping the idempotency key holds, and there is no +/// field on it that could cause a charge. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileSettlementRequest { + /// Field 1: `consumer_id` + #[serde( + rename = "consumerId", + alias = "consumer_id", + with = "::buffa::json_helpers::proto_string" + )] + pub consumer_id: ::buffa::alloc::string::String, + /// Field 2: `settlement_id` + #[serde( + rename = "settlementId", + alias = "settlement_id", + with = "::buffa::json_helpers::proto_string" + )] + pub settlement_id: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for ReconcileSettlementRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileSettlementRequest") + .field("consumer_id", &self.consumer_id) + .field("settlement_id", &self.settlement_id) + .finish() + } +} +impl ReconcileSettlementRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest"; +} +::buffa::impl_default_instance!(ReconcileSettlementRequest); +impl ::buffa::MessageName for ReconcileSettlementRequest { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ReconcileSettlementRequest"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest"; +} +impl ::buffa::Message for ReconcileSettlementRequest { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.consumer_id) as u64; + size += 1u64 + ::buffa::types::string_encoded_len(&self.settlement_id) as u64; + ::buffa::saturate_size(size) + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_string_field(1u32, &self.consumer_id, buf); + ::buffa::types::put_string_field(2u32, &self.settlement_id, buf); + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.consumer_id, buf)?; + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::types::merge_string(&mut self.settlement_id, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.consumer_id.clear(); + self.settlement_id.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileSettlementRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_SETTLEMENT_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// ReconcileSettlementResponse is what the provider says it knows. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReconcileSettlementResponse { + /// Field 1: `outcome` + #[serde(rename = "outcome", with = "::buffa::json_helpers::proto_enum")] + pub outcome: ::buffa::EnumValue, + /// The updated ledger record, so a caller never has to reconstruct the new + /// state from the outcome and hope its transition table matches the server's. + /// + /// Field 2: `record` + #[serde(rename = "record")] + pub record: ::buffa::MessageField< + SettlementRecord, + ::buffa::Inline, + >, + /// Field 3: `observed_at` + #[serde(rename = "observedAt", alias = "observed_at")] + pub observed_at: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>, + >, +} +impl ::core::fmt::Debug for ReconcileSettlementResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReconcileSettlementResponse") + .field("outcome", &self.outcome) + .field("record", &self.record) + .field("observed_at", &self.observed_at) + .finish() + } +} +impl ReconcileSettlementResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse"; +} +::buffa::impl_default_instance!(ReconcileSettlementResponse); +impl ::buffa::MessageName for ReconcileSettlementResponse { + const PACKAGE: &'static str = "trogonai.usage.settlement.v1alpha1"; + const NAME: &'static str = "ReconcileSettlementResponse"; + const FULL_NAME: &'static str = "trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse"; +} +impl ::buffa::Message for ReconcileSettlementResponse { + /// Returns the total encoded size in bytes. + /// + /// Accumulates in `u64` (which cannot overflow for in-memory + /// data) and saturates to `u32` at return, so a message whose + /// encoded size exceeds the 2 GiB protobuf limit yields a value + /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry + /// points reject, never a silently wrapped size. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u64; + { + let val = self.outcome.to_i32(); + size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64; + } + if self.record.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.record.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + if self.observed_at.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.observed_at.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64 + + inner_size as u64; + } + ::buffa::saturate_size(size) + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::EncodeSink, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + ::buffa::types::put_int32_field(1u32, self.outcome.to_i32(), buf); + if self.record.is_set() { + ::buffa::types::put_len_delimited_header( + 2u32, + u64::from(__cache.consume_next()), + buf, + ); + self.record.write_to(__cache, buf); + } + if self.observed_at.is_set() { + ::buffa::types::put_len_delimited_header( + 3u32, + u64::from(__cache.consume_next()), + buf, + ); + self.observed_at.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + ctx: ::buffa::DecodeContext<'_>, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::Varint, + )?; + self.outcome = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + 2u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.record.get_or_insert_default(), + buf, + ctx, + )?; + } + 3u32 => { + ::buffa::encoding::check_wire_type( + tag, + ::buffa::encoding::WireType::LengthDelimited, + )?; + ::buffa::Message::merge_length_delimited( + self.observed_at.get_or_insert_default(), + buf, + ctx, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.outcome = ::buffa::EnumValue::from(0); + self.record = ::buffa::MessageField::none(); + self.observed_at = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReconcileSettlementResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RECONCILE_SETTLEMENT_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/trogonai.usage.settlement.v1alpha1.ReconcileSettlementResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/lib.rs b/rsworkspace/crates/platform/trogonai-proto/src/lib.rs index d260fb3f13..f16f14eac6 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/lib.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/lib.rs @@ -48,6 +48,14 @@ pub mod content { } } +#[cfg(feature = "sessions")] +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod usage { + pub mod settlement_v1alpha1 { + pub use crate::r#gen::trogonai::usage::settlement::v1alpha1::*; + } +} + #[cfg(any(feature = "schedules", feature = "agents", feature = "decider"))] #[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] pub mod google { diff --git a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec.rs b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec.rs index cdf00fe1e5..dbf752224a 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec.rs @@ -55,12 +55,14 @@ fn encode_session_event_case(event: &SessionEventCase) -> Vec { SessionEventCase::SessionFailed(inner) => inner.encode_to_vec(), SessionEventCase::SessionHidden(inner) => inner.encode_to_vec(), SessionEventCase::SessionForked(inner) => inner.encode_to_vec(), + SessionEventCase::SessionRecovered(inner) => inner.encode_to_vec(), SessionEventCase::SessionRewound(inner) => inner.encode_to_vec(), SessionEventCase::Compacted(inner) => inner.encode_to_vec(), SessionEventCase::UserMessageRecorded(inner) => inner.encode_to_vec(), SessionEventCase::AssistantMessageStarted(inner) => inner.encode_to_vec(), SessionEventCase::AssistantMessageCompleted(inner) => inner.encode_to_vec(), SessionEventCase::AssistantMessageFailed(inner) => inner.encode_to_vec(), + SessionEventCase::ProviderToolIntentRejected(inner) => inner.encode_to_vec(), SessionEventCase::ToolCallRequested(inner) => inner.encode_to_vec(), SessionEventCase::ToolCallApproved(inner) => inner.encode_to_vec(), SessionEventCase::ToolCallDenied(inner) => inner.encode_to_vec(), @@ -100,6 +102,7 @@ fn decode_session_event_case(event: EventData<'_>) -> Result(&event)) .or_else(|| decode_event_case::(&event)) .or_else(|| decode_event_case::(&event)) + .or_else(|| decode_event_case::(&event)) .or_else(|| decode_event_case::(&event)) .or_else(|| decode_event_case::(&event)) .or_else(|| decode_event_case::(&event)) @@ -135,6 +138,7 @@ fn decode_session_event_case(event: EventData<'_>) -> Result(&event)) .or_else(|| decode_event_case::(&event)) .or_else(|| decode_event_case::(&event)) + .or_else(|| decode_event_case::(&event)) else { return Ok(None); }; @@ -150,6 +154,7 @@ fn session_event_case_type(event: &SessionEventCase) -> &'static str { SessionEventCase::SessionFailed(_) => event_type::(), SessionEventCase::SessionHidden(_) => event_type::(), SessionEventCase::SessionForked(_) => event_type::(), + SessionEventCase::SessionRecovered(_) => event_type::(), SessionEventCase::SessionRewound(_) => event_type::(), SessionEventCase::Compacted(_) => event_type::(), SessionEventCase::UserMessageRecorded(_) => event_type::(), @@ -185,6 +190,7 @@ fn session_event_case_type(event: &SessionEventCase) -> &'static str { SessionEventCase::SessionRenamed(_) => event_type::(), SessionEventCase::SessionArchived(_) => event_type::(), SessionEventCase::SessionUnarchived(_) => event_type::(), + SessionEventCase::ProviderToolIntentRejected(_) => event_type::(), } } diff --git a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec/tests.rs b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec/tests.rs index de417cddaa..76638f5fc4 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec/tests.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/codec/tests.rs @@ -117,6 +117,18 @@ fn session_forked() -> v1alpha1::SessionForked { } } +fn session_recovered() -> v1alpha1::SessionRecovered { + v1alpha1::SessionRecovered { + session_id: "session-1".to_string(), + source_session_id: "session-0".to_string(), + source_boundary: MessageField::some(session_ordinal(7)), + source_digest: MessageField::some(digest()), + salvage_key: "salvage-1".to_string(), + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Partial), + omitted_count: 2, + } +} + fn session_rewound() -> v1alpha1::SessionRewound { v1alpha1::SessionRewound { session_id: "session-1".to_string(), @@ -255,6 +267,10 @@ fn tool_call_started() -> v1alpha1::ToolCallStarted { fn tool_call_completed() -> v1alpha1::ToolCallCompleted { v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -270,6 +286,7 @@ fn tool_call_completed() -> v1alpha1::ToolCallCompleted { duration: MessageField::none(), observed: Vec::new(), termination: MessageField::none(), + output_replay: MessageField::none(), turn_id: "turn-1".to_string(), } } @@ -299,6 +316,7 @@ fn artifact_recorded() -> v1alpha1::ArtifactRecorded { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -307,6 +325,7 @@ fn artifact_recorded() -> v1alpha1::ArtifactRecorded { fn file_changed() -> v1alpha1::FileChanged { v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/main.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -514,6 +533,20 @@ fn session_unarchived() -> v1alpha1::SessionUnarchived { } } +fn provider_tool_intent_rejected() -> v1alpha1::ProviderToolIntentRejected { + v1alpha1::ProviderToolIntentRejected { + session_id: "session-1".to_string(), + rejection_id: "rejection-1".to_string(), + message_id: "message-1".to_string(), + turn_id: "turn-1".to_string(), + reason: buffa::EnumValue::from(v1alpha1::ProviderToolIntentRejectionReason::MalformedArguments), + claimed_tool_call_id: None, + claimed_tool_name: None, + raw_intent: MessageField::none(), + detail: None, + } +} + fn all_session_events() -> Vec { vec![ v1alpha1::SessionEvent { @@ -639,6 +672,12 @@ fn all_session_events() -> Vec { v1alpha1::SessionEvent { event: Some(session_unarchived().into()), }, + v1alpha1::SessionEvent { + event: Some(session_recovered().into()), + }, + v1alpha1::SessionEvent { + event: Some(provider_tool_intent_rejected().into()), + }, ] } @@ -670,6 +709,10 @@ fn assert_variant_round_trips(event: &v1alpha1::SessionEvent, encoded: &[u8]) -> assert_eq!(v1alpha1::SessionForked::decode_from_slice(encoded).unwrap(), **inner); ::FULL_NAME } + SessionEventCase::SessionRecovered(inner) => { + assert_eq!(v1alpha1::SessionRecovered::decode_from_slice(encoded).unwrap(), **inner); + ::FULL_NAME + } SessionEventCase::SessionRewound(inner) => { assert_eq!(v1alpha1::SessionRewound::decode_from_slice(encoded).unwrap(), **inner); ::FULL_NAME @@ -867,6 +910,13 @@ fn assert_variant_round_trips(event: &v1alpha1::SessionEvent, encoded: &[u8]) -> ); ::FULL_NAME } + SessionEventCase::ProviderToolIntentRejected(inner) => { + assert_eq!( + v1alpha1::ProviderToolIntentRejected::decode_from_slice(encoded).unwrap(), + **inner + ); + ::FULL_NAME + } } } @@ -1018,6 +1068,10 @@ fn tool_call_completed_round_trips_termination_duration_and_observations() { assert_round_trips(v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, termination: MessageField::some(v1alpha1::CommandTermination { outcome: Some(v1alpha1::command_termination::Outcome::ExitCode(2)), }), @@ -1052,6 +1106,10 @@ fn tool_call_completed_round_trips_signal_termination() { assert_round_trips(v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, termination: MessageField::some(v1alpha1::CommandTermination { outcome: Some(v1alpha1::command_termination::Outcome::Signal(9)), }), @@ -1067,6 +1125,7 @@ fn file_changed_round_trips_diff_summary() { assert_round_trips(v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), diff: MessageField::some(v1alpha1::DiffSummary { added_lines: Some(12), removed_lines: Some(3), diff --git a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/mod.rs b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/mod.rs index f094b14a29..450309b081 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/mod.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/mod.rs @@ -1,8 +1,43 @@ mod codec; mod validate; -// Thin wrapper that re-exports the generated proto package, emitted as an inline -// module tree that mirrors the codegen layout. +// Thin wrappers that re-export the generated proto packages, emitted as inline +// module trees that mirror the codegen layout. +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod artifacts_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::artifacts::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod diff_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::diff::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod doctor_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::doctor::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod maintenance_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::maintenance::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod queries_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::queries::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod replay_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::replay::v1alpha1::*; +} + +#[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] +pub mod state_v1alpha1 { + pub use crate::r#gen::trogonai::session::sessions::state::v1alpha1::*; +} + #[cfg_attr(dylint_lib = "trogon_lints", allow(inline_module_block))] pub mod v1alpha1 { pub use crate::r#gen::trogonai::session::sessions::v1alpha1::*; diff --git a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate.rs b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate.rs index cfbac9b681..7424b62936 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate.rs @@ -28,6 +28,7 @@ pub fn validate_session_event(event: &v1alpha1::SessionEvent) -> Result<(), Sess SessionEventCase::SessionFailed(inner) => validate_session_failed(inner), SessionEventCase::SessionHidden(inner) => validate_session_hidden(inner), SessionEventCase::SessionForked(inner) => validate_session_forked(inner), + SessionEventCase::SessionRecovered(inner) => validate_session_recovered(inner), SessionEventCase::SessionRewound(inner) => validate_session_rewound(inner), SessionEventCase::Compacted(inner) => validate_compacted(inner), SessionEventCase::UserMessageRecorded(inner) => validate_user_message_recorded(inner), @@ -36,6 +37,7 @@ pub fn validate_session_event(event: &v1alpha1::SessionEvent) -> Result<(), Sess SessionEventCase::AssistantMessageFailed(inner) => validate_assistant_message_failed(inner), SessionEventCase::ToolCallRequested(inner) => validate_tool_call_requested(inner), SessionEventCase::ToolCallApproved(inner) => validate_tool_call_approved(inner), + SessionEventCase::ProviderToolIntentRejected(inner) => validate_provider_tool_intent_rejected(inner), SessionEventCase::ToolCallDenied(inner) => validate_tool_call_denied(inner), SessionEventCase::ToolCallStarted(inner) => validate_tool_call_started(inner), SessionEventCase::ToolCallCompleted(inner) => validate_tool_call_completed(inner), @@ -141,6 +143,12 @@ pub enum SessionEventValidationError { #[error("restored_checkpoint.session_execution_plan_digest must match session_execution_plan_digest")] RestoredCheckpointPlanDigestMismatch, + #[error("omitted_count must be 0 when completeness is COMPLETE, got {actual}")] + CompleteRecoveryWithOmissions { actual: u32 }, + + #[error("omitted_count must be >= 1 when completeness is PARTIAL")] + PartialRecoveryWithoutOmissions, + #[error("{field} must be well-formed JSON")] InvalidJson { field: &'static str }, @@ -559,6 +567,32 @@ fn validate_session_forked(event: &v1alpha1::SessionForked) -> Result<(), Sessio require_known_nonzero(event.reason, "reason") } +fn validate_session_recovered(event: &v1alpha1::SessionRecovered) -> Result<(), SessionEventValidationError> { + require_non_empty(&event.session_id, "session_id")?; + require_non_empty(&event.source_session_id, "source_session_id")?; + require_positive_ordinal(&event.source_boundary, "source_boundary")?; + let source_digest = event + .source_digest + .as_option() + .ok_or(SessionEventValidationError::MissingRequiredField { field: "source_digest" })?; + require_digest(source_digest, "source_digest")?; + require_non_empty(&event.salvage_key, "salvage_key")?; + require_known_nonzero(event.completeness, "completeness")?; + // A complete recovery that lost something, or a partial one that lost + // nothing, would let a reader draw the opposite conclusion from each field. + match event.completeness.as_known() { + Some(v1alpha1::RecoveryCompleteness::Complete) if event.omitted_count != 0 => { + Err(SessionEventValidationError::CompleteRecoveryWithOmissions { + actual: event.omitted_count, + }) + } + Some(v1alpha1::RecoveryCompleteness::Partial) if event.omitted_count == 0 => { + Err(SessionEventValidationError::PartialRecoveryWithoutOmissions) + } + _ => Ok(()), + } +} + fn validate_session_rewound(event: &v1alpha1::SessionRewound) -> Result<(), SessionEventValidationError> { require_non_empty(&event.session_id, "session_id")?; require_positive_ordinal(&event.keep_through, "keep_through")?; @@ -989,6 +1023,16 @@ fn validate_todo_updated(event: &v1alpha1::TodoUpdated) -> Result<(), SessionEve Ok(()) } +fn validate_provider_tool_intent_rejected( + event: &v1alpha1::ProviderToolIntentRejected, +) -> Result<(), SessionEventValidationError> { + require_non_empty(&event.session_id, "session_id")?; + require_non_empty(&event.rejection_id, "rejection_id")?; + require_non_empty(&event.message_id, "message_id")?; + require_non_empty(&event.turn_id, "turn_id")?; + require_known_nonzero(event.reason, "reason") +} + fn validate_session_renamed(event: &v1alpha1::SessionRenamed) -> Result<(), SessionEventValidationError> { require_non_empty(&event.session_id, "session_id")?; require_non_empty(&event.display_name, "display_name") diff --git a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate/tests.rs b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate/tests.rs index 66061ffebc..3abead8818 100644 --- a/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate/tests.rs +++ b/rsworkspace/crates/platform/trogonai-proto/src/session/sessions/validate/tests.rs @@ -93,6 +93,10 @@ fn assistant_message_started() -> v1alpha1::AssistantMessageStarted { fn tool_call_completed() -> v1alpha1::ToolCallCompleted { v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -107,6 +111,7 @@ fn tool_call_completed() -> v1alpha1::ToolCallCompleted { }), turn_id: "turn-1".to_string(), termination: MessageField::none(), + output_replay: MessageField::none(), duration: MessageField::none(), observed: Vec::new(), } @@ -114,6 +119,7 @@ fn tool_call_completed() -> v1alpha1::ToolCallCompleted { fn file_changed() -> v1alpha1::FileChanged { v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -346,6 +352,10 @@ fn validate_tool_call_completed_rejects_missing_result_kind() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -357,6 +367,7 @@ fn validate_tool_call_completed_rejects_missing_result_kind() { observed: Vec::new(), termination: MessageField::none(), turn_id: "turn-1".to_string(), + output_replay: MessageField::none(), } .into(), ), @@ -477,6 +488,7 @@ fn validate_file_changed_rejects_renamed_without_previous_path() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Renamed), @@ -502,6 +514,7 @@ fn validate_file_changed_rejects_non_renamed_with_previous_path() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -527,6 +540,7 @@ fn validate_file_changed_accepts_renamed_with_previous_path() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Renamed), @@ -2133,6 +2147,65 @@ fn validate_artifact_erased_accepts_valid_event() { assert_eq!(validate_session_event(&event), Ok(())); } +#[test] +fn validate_provider_tool_intent_rejected_accepts_valid_event() { + let event = v1alpha1::SessionEvent { + event: Some(provider_tool_intent_rejected().into()), + }; + + assert_eq!(validate_session_event(&event), Ok(())); +} + +#[test] +fn validate_provider_tool_intent_rejected_rejects_empty_rejection_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::ProviderToolIntentRejected { + rejection_id: String::new(), + ..provider_tool_intent_rejected() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "rejection_id" }) + ); +} + +#[test] +fn validate_provider_tool_intent_rejected_rejects_unspecified_reason() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::ProviderToolIntentRejected { + reason: buffa::EnumValue::from(v1alpha1::ProviderToolIntentRejectionReason::Unspecified), + ..provider_tool_intent_rejected() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::UnspecifiedEnum { field: "reason" }) + ); +} + +fn provider_tool_intent_rejected() -> v1alpha1::ProviderToolIntentRejected { + v1alpha1::ProviderToolIntentRejected { + session_id: "session-1".to_string(), + rejection_id: "rejection-1".to_string(), + message_id: "message-1".to_string(), + turn_id: "turn-1".to_string(), + reason: buffa::EnumValue::from(v1alpha1::ProviderToolIntentRejectionReason::DuplicateCallId), + claimed_tool_call_id: Some("dup-1".to_string()), + claimed_tool_name: Some("Read".to_string()), + raw_intent: MessageField::none(), + detail: None, + } +} + #[test] fn validate_session_renamed_accepts_valid_event() { let event = v1alpha1::SessionEvent { @@ -2224,6 +2297,10 @@ fn validate_tool_call_completed_accepts_valid_event() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -2240,6 +2317,7 @@ fn validate_tool_call_completed_accepts_valid_event() { observed: Vec::new(), termination: MessageField::none(), turn_id: "turn-1".to_string(), + output_replay: MessageField::none(), } .into(), ), @@ -2265,6 +2343,7 @@ fn validate_artifact_recorded_accepts_valid_event() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -2674,6 +2753,10 @@ fn validate_tool_call_completed_accepts_artifact_ref_result() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -2685,6 +2768,7 @@ fn validate_tool_call_completed_accepts_artifact_ref_result() { observed: Vec::new(), termination: MessageField::none(), turn_id: "turn-1".to_string(), + output_replay: MessageField::none(), } .into(), ), @@ -2701,6 +2785,10 @@ fn validate_tool_call_completed_rejects_invalid_artifact_ref_result() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -2714,6 +2802,7 @@ fn validate_tool_call_completed_rejects_invalid_artifact_ref_result() { observed: Vec::new(), termination: MessageField::none(), turn_id: "turn-1".to_string(), + output_replay: MessageField::none(), } .into(), ), @@ -2732,6 +2821,7 @@ fn validate_file_changed_accepts_valid_before_and_after_ref() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -2757,6 +2847,7 @@ fn validate_file_changed_rejects_invalid_before_ref() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -2787,6 +2878,7 @@ fn validate_file_changed_rejects_invalid_after_ref() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::FileChanged { + copied_from: MessageField::none(), session_id: "session-1".to_string(), path: "src/new.rs".to_string(), change_kind: buffa::EnumValue::from(v1alpha1::FileChangeKind::Modified), @@ -3008,6 +3100,7 @@ fn validate_artifact_recorded_rejects_stored_source_invalid_digest() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -3041,6 +3134,7 @@ fn validate_artifact_recorded_rejects_stored_source_empty_storage_ref() { size_bytes: 128, storage_ref: String::new(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -3074,6 +3168,7 @@ fn validate_artifact_recorded_rejects_stored_source_empty_mime() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: String::new(), + chunks: MessageField::none(), }, ))), }), @@ -3535,6 +3630,10 @@ fn validate_tool_call_completed_rejects_empty_text_result_content() { let event = v1alpha1::SessionEvent { event: Some( v1alpha1::ToolCallCompleted { + detached: MessageField::none(), + accessed: Vec::new(), + failed_targets: Vec::new(), + targets_attempted: None, session_id: "session-1".to_string(), tool_call_id: "tool-call-1".to_string(), tool_execution_id: "tool-exec-1".to_string(), @@ -3551,6 +3650,7 @@ fn validate_tool_call_completed_rejects_empty_text_result_content() { observed: Vec::new(), termination: MessageField::none(), turn_id: "turn-1".to_string(), + output_replay: MessageField::none(), } .into(), ), @@ -3888,6 +3988,7 @@ fn validate_artifact_recorded_accepts_valid_created_at() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -3916,6 +4017,7 @@ fn validate_artifact_recorded_rejects_invalid_created_at() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -3949,6 +4051,7 @@ fn validate_artifact_recorded_rejects_missing_created_at() { size_bytes: 128, storage_ref: "blob://artifact-1".to_string(), mime: "text/plain".to_string(), + chunks: MessageField::none(), }, ))), }), @@ -5138,3 +5241,265 @@ fn validate_user_message_recorded_rejects_provider_block_invalid_ref_payload() { }) ); } + +fn session_recovered() -> v1alpha1::SessionRecovered { + v1alpha1::SessionRecovered { + session_id: "session-1".to_string(), + source_session_id: "session-0".to_string(), + source_boundary: MessageField::some(session_ordinal(7)), + source_digest: MessageField::some(digest()), + salvage_key: "salvage-1".to_string(), + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Complete), + omitted_count: 0, + } +} + +#[test] +fn validate_session_recovered_accepts_complete_without_omissions() { + let event = v1alpha1::SessionEvent { + event: Some(session_recovered().into()), + }; + + assert_eq!(validate_session_event(&event), Ok(())); +} + +#[test] +fn validate_session_recovered_accepts_partial_with_omissions() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Partial), + omitted_count: 3, + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!(validate_session_event(&event), Ok(())); +} + +#[test] +fn validate_session_recovered_rejects_empty_session_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + session_id: String::new(), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "session_id" }) + ); +} + +#[test] +fn validate_session_recovered_rejects_empty_source_session_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + source_session_id: String::new(), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { + field: "source_session_id" + }) + ); +} + +#[test] +fn validate_session_recovered_rejects_zero_source_boundary() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + source_boundary: MessageField::some(session_ordinal(0)), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::OrdinalNotPositive { + field: "source_boundary" + }) + ); +} + +#[test] +fn validate_session_recovered_rejects_missing_source_digest() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + source_digest: MessageField::none(), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::MissingRequiredField { field: "source_digest" }) + ); +} + +#[test] +fn validate_session_recovered_rejects_unsupported_source_digest_algorithm() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + source_digest: MessageField::some(v1alpha1::Digest { + algorithm: "md5".to_string(), + value: vec![0u8; 16], + }), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::UnsupportedDigestAlgorithm { field: "source_digest" }) + ); +} + +#[test] +fn validate_session_recovered_rejects_empty_salvage_key() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + salvage_key: String::new(), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "salvage_key" }) + ); +} + +#[test] +fn validate_session_recovered_rejects_unspecified_completeness() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Unspecified), + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::UnspecifiedEnum { field: "completeness" }) + ); +} + +#[test] +fn validate_session_recovered_rejects_complete_with_omissions() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Complete), + omitted_count: 2, + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::CompleteRecoveryWithOmissions { actual: 2 }) + ); +} + +#[test] +fn validate_session_recovered_rejects_partial_without_omissions() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::SessionRecovered { + completeness: buffa::EnumValue::from(v1alpha1::RecoveryCompleteness::Partial), + omitted_count: 0, + ..session_recovered() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::PartialRecoveryWithoutOmissions) + ); +} + +#[test] +fn validate_provider_tool_intent_rejected_rejects_empty_session_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::ProviderToolIntentRejected { + session_id: String::new(), + ..provider_tool_intent_rejected() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "session_id" }) + ); +} + +#[test] +fn validate_provider_tool_intent_rejected_rejects_empty_message_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::ProviderToolIntentRejected { + message_id: String::new(), + ..provider_tool_intent_rejected() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "message_id" }) + ); +} + +#[test] +fn validate_provider_tool_intent_rejected_rejects_empty_turn_id() { + let event = v1alpha1::SessionEvent { + event: Some( + v1alpha1::ProviderToolIntentRejected { + turn_id: String::new(), + ..provider_tool_intent_rejected() + } + .into(), + ), + }; + + assert_eq!( + validate_session_event(&event), + Err(SessionEventValidationError::EmptyIdentifier { field: "turn_id" }) + ); +}