ai_memory/models/field_names.rs
1// Copyright 2026 AlphaOne LLC
2// SPDX-License-Identifier: Apache-2.0
3//
4// Crate-wide SSOT for JSON/row FIELD-NAME strings (#1558 batch 5 wave 4).
5//
6// Every wire-payload object key (`json!({...})`), `serde_json::Value`
7// extraction key (`.get("x")` / `["x"]`), and DB row column-name string
8// (sqlx `row.try_get("x")`, rusqlite `row.get("x")`, standalone
9// column-name arguments) that is duplicated across production sites
10// references ONE named const here instead of a scattered literal, per
11// the pm-v3.1 hardcoded-literal lint-gate
12// (`scripts/check-hardcoded-literals.sh`).
13//
14// Position classes routed here:
15// - `json!({ (field_names::CREATED_AT): value, ... })` — the
16// parenthesized-key form (compile-verified pattern; see
17// `crate::handlers::QUOTA_REFUSED_FIELD` usage from wave 3).
18// - `.get(field_names::X)` / `[field_names::X]` on response/row JSON.
19// - sqlx / rusqlite column-name arguments.
20//
21// NOT routed here:
22// - serde attribute positions (`#[serde(rename/alias)]`), derive-macro
23// positions, thiserror `#[error]` strings, struct field identifiers.
24// - Names embedded inside larger SQL statement strings — SQL text is
25// left alone entirely.
26//
27// Relationship to `crate::mcp::param_names`: that module remains the
28// public SSOT surface for MCP tool-call parameter extraction. To keep a
29// single spelling per string, every param_names const whose name also
30// lives here is defined as an alias of the corresponding const below.
31//
32// Keep alphabetical. Const name mirrors the canonical snake_case JSON
33// key / column spelling in UPPER_SNAKE.
34
35/// `access_count` — wire/row field name.
36pub const ACCESS_COUNT: &str = "access_count";
37/// `action_type` — wire/row field name.
38pub const ACTION_TYPE: &str = "action_type";
39/// `agent_filter` — wire/row field name.
40pub const AGENT_FILTER: &str = "agent_filter";
41/// `agent_pubkey` — wire/row field name.
42pub const AGENT_PUBKEY: &str = "agent_pubkey";
43/// `agent_type` — wire/row field name.
44pub const AGENT_TYPE: &str = "agent_type";
45/// `allowed_tools` — wire/row field name.
46pub const ALLOWED_TOOLS: &str = "allowed_tools";
47/// `archived_at` — wire/row field name.
48pub const ARCHIVED_AT: &str = "archived_at";
49/// `archive_reason` — wire/row field name.
50pub const ARCHIVE_REASON: &str = "archive_reason";
51/// `atomisation_archived_at` — wire/row field name.
52pub const ATOMISATION_ARCHIVED_AT: &str = "atomisation_archived_at";
53/// `atom_count` — wire/row field name.
54pub const ATOM_COUNT: &str = "atom_count";
55/// `atomised_into` — wire/row field name (#1637 archive projection).
56pub const ATOMISED_INTO: &str = "atomised_into";
57/// `atom_of` — wire/row field name (#1637 archive projection).
58pub const ATOM_OF: &str = "atom_of";
59/// `mentioned_entity_id` — wire/row field name (#1637 archive projection).
60pub const MENTIONED_ENTITY_ID: &str = "mentioned_entity_id";
61/// `attest_level` — wire/row field name.
62pub const ATTEST_LEVEL: &str = "attest_level";
63/// `budget_tokens` — wire/row field name.
64pub const BUDGET_TOKENS: &str = "budget_tokens";
65/// `by_namespace` — wire/row field name.
66pub const BY_NAMESPACE: &str = "by_namespace";
67/// `by_source_uri` — wire/row field name.
68pub const BY_SOURCE_URI: &str = "by_source_uri";
69/// `candidates_scanned` — wire/row field name.
70pub const CANDIDATES_SCANNED: &str = "candidates_scanned";
71/// `canonical_name` — wire/row field name.
72pub const CANONICAL_NAME: &str = "canonical_name";
73/// `capabilities` — wire/row field name.
74pub const CAPABILITIES: &str = "capabilities";
75/// `compatibility` — wire/row field name.
76pub const COMPATIBILITY: &str = "compatibility";
77/// `confidence` — wire/row field name.
78pub const CONFIDENCE: &str = "confidence";
79/// `confidence_decayed_at` — wire/row field name.
80pub const CONFIDENCE_DECAYED_AT: &str = "confidence_decayed_at";
81/// `confidence_signals` — wire/row field name.
82pub const CONFIDENCE_SIGNALS: &str = "confidence_signals";
83/// `confidence_source` — wire/row field name.
84pub const CONFIDENCE_SOURCE: &str = "confidence_source";
85/// `confirmed_contradictions` — wire/row field name.
86pub const CONFIRMED_CONTRADICTIONS: &str = "confirmed_contradictions";
87/// `consolidated` — wire/row field name.
88pub const CONSOLIDATED: &str = "consolidated";
89/// `content_sha256` — wire/row field name.
90pub const CONTENT_SHA256: &str = "content_sha256";
91/// `created_at` — wire/row field name.
92pub const CREATED_AT: &str = "created_at";
93/// `created_by` — wire/row field name.
94pub const CREATED_BY: &str = "created_by";
95/// `current_tier` — wire/row field name.
96pub const CURRENT_TIER: &str = "current_tier";
97/// `custom_kind` — wire/row field name.
98pub const CUSTOM_KIND: &str = "custom_kind";
99/// `decided_at` — wire/row field name.
100pub const DECIDED_AT: &str = "decided_at";
101/// `decided_by` — wire/row field name.
102pub const DECIDED_BY: &str = "decided_by";
103/// `default_timeout_seconds` — wire/row field name.
104pub const DEFAULT_TIMEOUT_SECONDS: &str = "default_timeout_seconds";
105/// `description` — wire/row field name.
106pub const DESCRIPTION: &str = "description";
107/// `earliest_updated_at` — wire/row field name.
108pub const EARLIEST_UPDATED_AT: &str = "earliest_updated_at";
109/// `elapsed_ms` — wire/row field name.
110pub const ELAPSED_MS: &str = "elapsed_ms";
111/// `embeddings` — wire field name. Federation `/sync/push` payloads
112/// carry shipped source-side embedding vectors under this key
113/// (#1566 / #1579 B1 embed-once-replicate-vector). The array lives
114/// inside the Ed25519-signed body bytes; decode is tolerant of the
115/// field's absence so older peers interoperate.
116pub const EMBEDDINGS: &str = "embeddings";
117/// `embedding_dim` — wire/row field name (#1169 dim reporting; #1598
118/// `ResolvedEmbeddings` Debug field).
119pub const EMBEDDING_DIM: &str = "embedding_dim";
120/// `entity_id` — metadata key naming the entity a reflection is about
121/// (drives auto-persona cadence via the denormalised
122/// [`MENTIONED_ENTITY_ID`] column). Canonical spelling SSOT; the MCP
123/// param `crate::mcp::param_names::ENTITY_ID` aliases this const (#1665).
124pub const ENTITY_ID: &str = "entity_id";
125/// `event_types` — wire/row field name.
126pub const EVENT_TYPES: &str = "event_types";
127/// `excluded_for_scope` — wire/row field name.
128pub const EXCLUDED_FOR_SCOPE: &str = "excluded_for_scope";
129/// `excluded_for_scope_private` — wire/row field name.
130pub const EXCLUDED_FOR_SCOPE_PRIVATE: &str = "excluded_for_scope_private";
131/// `expanded_terms` — wire/row field name.
132pub const EXPANDED_TERMS: &str = "expanded_terms";
133/// `expired_at` — wire/row field name.
134pub const EXPIRED_AT: &str = "expired_at";
135/// `expired_deleted` — wire/row field name.
136pub const EXPIRED_DELETED: &str = "expired_deleted";
137/// `expires_at` — wire/row field name.
138pub const EXPIRES_AT: &str = "expires_at";
139/// `exported_at` — wire/row field name.
140pub const EXPORTED_AT: &str = "exported_at";
141/// `from_agent_id` — wire/row field name.
142pub const FROM_AGENT_ID: &str = "from_agent_id";
143/// `generated_at` — wire/row field name.
144pub const GENERATED_AT: &str = "generated_at";
145/// `governance` — wire/row field name.
146pub const GOVERNANCE: &str = "governance";
147/// `imported_from_agent_id` — wire/row field name.
148pub const IMPORTED_FROM_AGENT_ID: &str = "imported_from_agent_id";
149/// `include_invalidated` — wire/row field name.
150pub const INCLUDE_INVALIDATED: &str = "include_invalidated";
151/// `is_duplicate` — wire/row field name.
152pub const IS_DUPLICATE: &str = "is_duplicate";
153/// `is_reflection` — wire/row field name.
154pub const IS_REFLECTION: &str = "is_reflection";
155/// `key_source` — wire/row field name.
156pub const KEY_SOURCE: &str = "key_source";
157/// `last_accessed_at` — wire/row field name.
158pub const LAST_ACCESSED_AT: &str = "last_accessed_at";
159/// `last_seen_at` — wire/row field name.
160pub const LAST_SEEN_AT: &str = "last_seen_at";
161/// `latency_ms` — wire/row field name.
162pub const LATENCY_MS: &str = "latency_ms";
163/// `latest_updated_at` — wire/row field name.
164pub const LATEST_UPDATED_AT: &str = "latest_updated_at";
165/// `local_depth_at_arrival` — wire/row field name.
166pub const LOCAL_DEPTH_AT_ARRIVAL: &str = "local_depth_at_arrival";
167/// `memories_dropped` — wire/row field name.
168pub const MEMORIES_DROPPED: &str = "memories_dropped";
169/// `memory_kind` — wire/row field name.
170pub const MEMORY_KIND: &str = "memory_kind";
171/// `namespaces` — wire/row field name.
172pub const NAMESPACES: &str = "namespaces";
173/// `namespace_filter` — wire/row field name.
174pub const NAMESPACE_FILTER: &str = "namespace_filter";
175/// `observations` — wire/row field name.
176pub const OBSERVATIONS: &str = "observations";
177/// `observed_by` — wire/row field name.
178pub const OBSERVED_BY: &str = "observed_by";
179/// `older_than_days` — wire/row field name.
180pub const OLDER_THAN_DAYS: &str = "older_than_days";
181/// `original_depth` — wire/row field name.
182pub const ORIGINAL_DEPTH: &str = "original_depth";
183/// `owner_scope` — wire/row field name.
184pub const OWNER_SCOPE: &str = "owner_scope";
185/// `parameters_schema` — wire/row field name.
186pub const PARAMETERS_SCHEMA: &str = "parameters_schema";
187/// `parent_namespace` — wire/row field name.
188pub const PARENT_NAMESPACE: &str = "parent_namespace";
189/// `peer_origin` — wire/row field name.
190pub const PEER_ORIGIN: &str = "peer_origin";
191/// `pending_id` — wire/row field name.
192pub const PENDING_ID: &str = "pending_id";
193/// `persona_version` — wire/row field name.
194pub const PERSONA_VERSION: &str = "persona_version";
195/// `previous_valid_until` — wire/row field name.
196pub const PREVIOUS_VALID_UNTIL: &str = "previous_valid_until";
197/// `properties` — wire/row field name (JSON-Schema object key).
198pub const PROPERTIES: &str = "properties";
199/// `reflection_depth` — wire/row field name.
200pub const REFLECTION_DEPTH: &str = "reflection_depth";
201/// `reflection_id` — wire/row field name.
202pub const REFLECTION_ID: &str = "reflection_id";
203/// `reflection_metadata` — wire/row field name.
204pub const REFLECTION_METADATA: &str = "reflection_metadata";
205/// `registered` — wire/row field name.
206pub const REGISTERED: &str = "registered";
207/// `registered_at` — wire/row field name.
208pub const REGISTERED_AT: &str = "registered_at";
209/// `requested_at` — wire/row field name.
210pub const REQUESTED_AT: &str = "requested_at";
211/// `requested_by` — wire/row field name.
212pub const REQUESTED_BY: &str = "requested_by";
213/// `required_tier` — wire/row field name.
214pub const REQUIRED_TIER: &str = "required_tier";
215/// `resource_path` — wire/row field name.
216pub const RESOURCE_PATH: &str = "resource_path";
217/// `schema_version` — wire/row field name.
218pub const SCHEMA_VERSION: &str = "schema_version";
219/// `scope_status` — wire/row field name.
220pub const SCOPE_STATUS: &str = "scope_status";
221/// `sender_agent_id` — wire/row field name.
222pub const SENDER_AGENT_ID: &str = "sender_agent_id";
223/// `signing_agent` — wire/row field name.
224pub const SIGNING_AGENT: &str = "signing_agent";
225/// `similarity` — wire/row field name.
226pub const SIMILARITY: &str = "similarity";
227/// `skill_description` — wire/row field name.
228pub const SKILL_DESCRIPTION: &str = "skill_description";
229/// `skill_name` — wire/row field name.
230pub const SKILL_NAME: &str = "skill_name";
231/// `source_ids` — wire/row field name.
232pub const SOURCE_IDS: &str = "source_ids";
233/// `source_memory_id` — wire/row field name.
234pub const SOURCE_MEMORY_ID: &str = "source_memory_id";
235/// `source_span` — wire/row field name.
236pub const SOURCE_SPAN: &str = "source_span";
237/// `source_uri` — wire/row field name.
238pub const SOURCE_URI: &str = "source_uri";
239/// `standard_id` — wire/row field name.
240pub const STANDARD_ID: &str = "standard_id";
241/// `storage_backend` — wire/row field name.
242pub const STORAGE_BACKEND: &str = "storage_backend";
243/// `subscription_id` — wire/row field name.
244pub const SUBSCRIPTION_ID: &str = "subscription_id";
245/// `subscriptions` — wire/row field name.
246pub const SUBSCRIPTIONS: &str = "subscriptions";
247/// `suggested_merge` — wire/row field name.
248pub const SUGGESTED_MERGE: &str = "suggested_merge";
249/// `superseded_id` — wire/row field name.
250pub const SUPERSEDED_ID: &str = "superseded_id";
251/// `synthesized` — wire/row field name.
252pub const SYNTHESIZED: &str = "synthesized";
253/// `target_agent_id` — wire/row field name.
254pub const TARGET_AGENT_ID: &str = "target_agent_id";
255/// `target_folder` — wire/row field name.
256pub const TARGET_FOLDER: &str = "target_folder";
257/// `target_namespace` — wire/row field name.
258pub const TARGET_NAMESPACE: &str = "target_namespace";
259/// `tier-locked` — wire/row field name.
260pub const TIER_LOCKED: &str = "tier-locked";
261/// `tokens_used` — wire/row field name.
262pub const TOKENS_USED: &str = "tokens_used";
263/// `total_count` — wire/row field name.
264pub const TOTAL_COUNT: &str = "total_count";
265/// `total_lines` — wire/row field name.
266pub const TOTAL_LINES: &str = "total_lines";
267/// `total_memories` — wire/row field name.
268pub const TOTAL_MEMORIES: &str = "total_memories";
269/// `to_namespace` — wire/row field name.
270pub const TO_NAMESPACE: &str = "to_namespace";
271/// `transcripts` — wire/row field name.
272pub const TRANSCRIPTS: &str = "transcripts";
273/// `unread_only` — wire/row field name.
274pub const UNREAD_ONLY: &str = "unread_only";
275/// `updated_at` — wire/row field name.
276pub const UPDATED_AT: &str = "updated_at";
277/// `updated_since` — wire/row field name.
278pub const UPDATED_SINCE: &str = "updated_since";
279/// `valid_from` — wire/row field name.
280pub const VALID_FROM: &str = "valid_from";
281/// `valid_until` — wire/row field name.
282pub const VALID_UNTIL: &str = "valid_until";