toga-ai 1.0.689 → 1.0.690

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ # talos-backend (TOGa IQ Backend) — 2.0 knowledge
2
+
3
+ | Doc | Summary | Files |
4
+ |-----|---------|-------|
5
+ | [Onboarding a TOGa Supply client to TOGa IQ Backend](workflows/toga-supply-client-onboarding.md) | The TOGa Supply AI launch is one cross-system workflow with two deliberately separate data planes: 1. | talos-backend/docs/toga-supply-client-onboarding-runbook.md, talos-backend/docs/tenant-assistant-onboarding.md, talos-backend/deployments/tenants/compass-usa/manifest.json, talos-backend/deployments/tenants/health-and-hospitals/manifest.json, talos-backend/scripts/onboard_tenant_assistant.py, talos-backend/scripts/update_langfuse_project_registry.py, talos-backend/mcp-servers/toga-platform-mcp/ |
@@ -0,0 +1,297 @@
1
+ ---
2
+ title: Onboarding a TOGa Supply client to TOGa IQ Backend
3
+ framework: "2.0"
4
+ repo: talos-backend
5
+ project: TOGa IQ Backend
6
+ client: shared
7
+ type: workflow
8
+ status: active
9
+ updated: 2026-08-28
10
+ owners: [akhokhani]
11
+ files:
12
+ - talos-backend/docs/toga-supply-client-onboarding-runbook.md
13
+ - talos-backend/docs/tenant-assistant-onboarding.md
14
+ - talos-backend/deployments/tenants/compass-usa/manifest.json
15
+ - talos-backend/deployments/tenants/health-and-hospitals/manifest.json
16
+ - talos-backend/scripts/onboard_tenant_assistant.py
17
+ - talos-backend/scripts/update_langfuse_project_registry.py
18
+ - talos-backend/mcp-servers/toga-platform-mcp/
19
+ related:
20
+ - ../../api2/features/record-scripts.md
21
+ - ../../toga2-supply/workflows/client-host-scoping.md
22
+ - ../../talos/features/observability.md
23
+ - ../../talos/features/mcp-servers.md
24
+ - ../../../../clients/compass-usa/profile.md
25
+ - ../../../../clients/nychh/profile.md
26
+ ---
27
+
28
+ ## Summary
29
+
30
+ The TOGa Supply AI launch is one cross-system workflow with two deliberately
31
+ separate data planes:
32
+
33
+ 1. **TOGaHub/api2 MySQL** owns the user, persona, AI-model grant, record-script
34
+ ACL, Supply records, and API2 business authorization. Talos does not use
35
+ these MySQL tables as its application database.
36
+ 2. **TOGa IQ Backend PostgreSQL** owns tenant routing, assistant configuration,
37
+ BLP, MCP assignments, threads, runs, checkpoints, and observability context.
38
+
39
+ At authentication time Talos sends the current bearer and exact Supply origin
40
+ to `GET /v2/users/me`. The response proves the client identity and supplies the
41
+ active persona-linked AI-model slugs. Talos admits the `toga-supply` assistant
42
+ only when that response contains an active `toga-supply` model. During a Supply
43
+ question, the shared `toga-platform` MCP forwards the same request-scoped bearer
44
+ to API2, whose record/field/script ACLs remain authoritative for business data.
45
+
46
+ The full executable SQL, curls, verification checklist, rollback procedure, and
47
+ OneUptime agent prompt live in
48
+ `talos-backend/docs/toga-supply-client-onboarding-runbook.md`. This knowledge
49
+ entry records the durable boundaries and ordering that future operators must not
50
+ lose.
51
+
52
+ ## Identity and naming contract
53
+
54
+ Do not collapse these values into one slug:
55
+
56
+ | Value | Authority | Example: NYCHH |
57
+ |---|---|---|
58
+ | TOGaHub client schema | API2 client database | `Client_Nychh` |
59
+ | canonical Talos org ID | JWT `id.client.slug` | `Nychh` |
60
+ | external organization identity | `/users/me` `audience.client` | `NYC Health + Hospitals` |
61
+ | Talos physical database | onboarding manifest | `tenant_nychh` |
62
+
63
+ Talos PostgreSQL databases always use `tenant_<normalized_org_id>`. A name such
64
+ as `iweb_nychh` is invalid for this deployment contract even if `iweb` is used
65
+ elsewhere in the customer's legacy stack.
66
+
67
+ Working reference mappings:
68
+
69
+ - Compass USA: `Compass_Usa` / `Compass Group` / `tenant_compass_usa`.
70
+ - NYC Health & Hospitals: `Nychh` / `NYC Health + Hospitals` / `tenant_nychh`.
71
+
72
+ Tenant resolution is exact and case-sensitive. Never add fuzzy matching or
73
+ client-name branches in Talos runtime code to compensate for a wrong control-
74
+ plane registration.
75
+
76
+ ## Ordered onboarding workflow
77
+
78
+ ### 1. Capture identity from a real beta login
79
+
80
+ Log in to the intended TOGaHub beta host with the client's exact Supply
81
+ `Origin`, then call `/v2/users/me` with the issued bearer. Record only non-secret
82
+ identity fields: client UUID, JWT client slug, `audience.client`, user UUID,
83
+ origin, and referer.
84
+
85
+ Stop if `/users/me` is not 200/success or resolves a different client. Do not
86
+ begin Talos provisioning with a guessed org ID.
87
+
88
+ ### 2. Enable `/users/me` in API2 MySQL
89
+
90
+ The global script definition is in the target environment's
91
+ `Core.RecordScripts`; the role grant is in the client database's
92
+ `AclRecordScripts`.
93
+
94
+ **`Core.RecordScripts.id` is not stable between environments.** The NYCHH
95
+ onboarding observed ID `21` for `/users/me`, but operators must query the target
96
+ Core database and verify route/method/record before using that number. This is
97
+ different from `Core.Records.id` and `Core.RecordFields.id`, which are team-
98
+ maintained platform constants.
99
+
100
+ Production physically separates Core and `Client_*` onto different clusters.
101
+ A client migration cannot query `Core.RecordScripts` at runtime. The operator
102
+ must discover the script ID on the Core connection, then apply the literal grant
103
+ on the client connection. A stale numeric grant inserts successfully but API2
104
+ rejects the request at runtime.
105
+
106
+ Resolve the Base role by name in each client database; do not assume its ID from
107
+ another client. Grant scripted access in `AclRecordScripts`. Do not add ordinary
108
+ record CREATE permissions to repair a scripted API 403: scripted calls bypass
109
+ the CRUD record-permission path.
110
+
111
+ ### 3. Create the TOGa Supply model/persona chain in client MySQL
112
+
113
+ Inside the intended `Client_<Name>` database, in one reviewed transaction:
114
+
115
+ 1. idempotently upsert active `AiModels.slug = 'toga-supply'`;
116
+ 2. idempotently create persona `All`;
117
+ 3. link the intended active users through `Users_Personas`;
118
+ 4. link `All` through `Personas_AiModels` to `toga-supply`;
119
+ 5. grant Base-role reads for the Personas, Users-Personas, AI Models, and
120
+ Personas-AI Models records;
121
+ 6. scope AI-model record reads to the TOGa Supply app where required; and
122
+ 7. grant read-only field permissions for every field needed by the nested
123
+ `/users/me` response.
124
+
125
+ NYCHH observed record IDs 40 (Personas), 201 (Users-Personas), 227 (AI Models),
126
+ and 228 (Personas-AI Models), with Base role 1 and Supply app 1. Verify every
127
+ target value before mutation. In particular, a record ID and record-field ID
128
+ are different namespaces even when their integers happen to match.
129
+
130
+ After commit, issue a new bearer and require:
131
+
132
+ ```text
133
+ data.users.me.userPersonas[*].persona.personaAiModels[*].aiModel
134
+ slug = toga-supply
135
+ isActive = true
136
+ ```
137
+
138
+ The API2/MySQL phase ends here. Talos never reads these MySQL tables directly
139
+ for authentication; `/users/me` is the trust boundary.
140
+
141
+ ### 4. Build the Talos deployment manifest
142
+
143
+ Copy the current declarative Supply tenant directory and replace every client-
144
+ specific value in `manifest.json`, `persona.txt`, and `toga-supply.blp`.
145
+
146
+ Required invariants:
147
+
148
+ - database name `tenant_<normalized_org_id>`;
149
+ - assistant, persona, and ACL slug `toga-supply`;
150
+ - graph `deep_agent`;
151
+ - exact native tool list `[query_business_logic]`;
152
+ - one required shared MCP, slug `toga-platform`;
153
+ - MCP transport `streamable_http` and auth type `user_bearer`;
154
+ - read-only customer persona and Supply BLP;
155
+ - no tenant name in MCP source code or tool-selection logic;
156
+ - approved primary and embedding Bedrock model profiles.
157
+
158
+ Never store a bearer or service secret in the manifest.
159
+
160
+ ### 5. Dry-run and apply the Talos reconciler
161
+
162
+ Run `scripts/onboard_tenant_assistant.py` without `--apply`, using the target
163
+ environment file. Review the exact AWS account, org ID, physical database name,
164
+ assistant, model, and profiles. Then repeat with `--apply --confirm-org` where
165
+ the confirmation exactly equals the manifest org ID.
166
+
167
+ The reconciler idempotently:
168
+
169
+ - verifies STS account identity;
170
+ - creates/reuses tagged Bedrock application inference profiles;
171
+ - creates the isolated PostgreSQL database;
172
+ - installs extensions and migrates to Alembic head;
173
+ - seeds normalized base infrastructure;
174
+ - writes `organizations` and `tenant_databases` in the control plane;
175
+ - reconciles the deterministic assistant, version, config, persona, model
176
+ preset, BLP, exact tool boundary, and shared MCP assignment; and
177
+ - runs a bounded Bedrock inference smoke test.
178
+
179
+ Do not manually create control-plane rows during a normal onboarding. Never
180
+ print `tenant_databases.database_url`; it may carry credentials.
181
+
182
+ ### 6. Create tenant-scoped Langfuse observability
183
+
184
+ Sign in at `langfuse.togaiq.com` with the approved development-team account from
185
+ 1Password. Select the existing organization; **do not create another
186
+ organization**. Create `<Client Name> - TOGa Supply`, generate API keys, and
187
+ store the project ID and keys directly in 1Password.
188
+
189
+ Run `scripts/update_langfuse_project_registry.py`. It receives keys through
190
+ hidden prompts, verifies them against the exact project ID, preserves other
191
+ tenants, and atomically updates `LANGFUSE_PROJECTS_JSON`. Every tenant/
192
+ environment needs an explicit entry; there is no implicit fallback. Different
193
+ tenants must never share a Langfuse project.
194
+
195
+ Restart API and worker processes after changing environment registry data.
196
+ Verify the first trace has exactly the intended canonical org/environment tags
197
+ and opens in the intended project.
198
+
199
+ ### 7. Configure OneUptime
200
+
201
+ Use the repository's `docs/oneuptime-integration-playbook.md` and existing
202
+ tenant-aware reporter. Find or create the monitor idempotently, persist the ID
203
+ in `organizations.oneuptime_monitor_id`, and use `/ready` as the critical Talos
204
+ contract. Preserve the consecutive-failure threshold; one transient failure
205
+ must not immediately publish degradation.
206
+
207
+ Beta must never report into production OneUptime resources. API keys remain in
208
+ the approved secret facility. Verify by reading the monitor back and observing
209
+ a fresh timestamp/status, not merely by receiving HTTP 200 from a heartbeat.
210
+
211
+ ### 8. Deploy one clean worker generation
212
+
213
+ Rebuild/restart the target environment and confirm only the intended API and
214
+ worker generation consumes its Redis queue. During Compass/NYCHH validation,
215
+ six orphaned reload workers running different revisions made failures appear
216
+ tenant-specific. Requests randomly reached stale code and returned `MCP action
217
+ is no longer available`.
218
+
219
+ Resolve exact process IDs before stopping stale processes; never use a broad
220
+ process-name kill on a shared host.
221
+
222
+ ### 9. Run the streaming release suite
223
+
224
+ Use a fresh bearer and the exact client Origin/Referer:
225
+
226
+ 1. `POST /threads` and retain the returned thread ID;
227
+ 2. `POST /threads/{thread_id}/runs/stream` with the tenant assistant ID;
228
+ 3. send stream modes `messages`, `updates`, and `custom` with
229
+ `on_disconnect = continue`;
230
+ 4. require an SSE `end` event, persisted successful run, and successful MCP
231
+ tool messages.
232
+
233
+ Ask at least these five questions:
234
+
235
+ 1. five most recent sales orders;
236
+ 2. five most recent pending-fulfillment orders;
237
+ 3. five most recent billed orders;
238
+ 4. five most recent fulfilled orders; and
239
+ 5. most recent order detail with lines, fulfillment, and approval information.
240
+
241
+ When the MCP serves multiple clients, execute all five concurrently for two
242
+ clients. Verify separate tenant databases, business records, trusted Supply
243
+ URLs, and Langfuse projects, with no cross-client data. API2 capabilities may
244
+ legitimately differ; missing/hidden data must be reported as partial or
245
+ unavailable rather than replaced with another client's behavior.
246
+
247
+ ## Release gates
248
+
249
+ - Beta passes before production begins.
250
+ - `/users/me` proves the exact client and active `toga-supply` grant.
251
+ - Talos control plane maps the exact org to `tenant_<normalized_org_id>`.
252
+ - Bedrock profiles are active, tagged, and reused idempotently.
253
+ - The assistant has only its declared BLP/tool/MCP capabilities.
254
+ - MCP auth is required `user_bearer`; no bearer is persisted.
255
+ - Langfuse trace and OneUptime monitor are tenant/environment correct.
256
+ - Five streaming questions pass, including concurrent cross-tenant isolation.
257
+ - The change record contains non-secret run IDs, trace URLs, timestamps, commit
258
+ SHA, operator, and reviewer.
259
+
260
+ ## Rollback
261
+
262
+ Prefer suspension and configuration rollback over deletion:
263
+
264
+ 1. suspend the Talos organization or stop client traffic;
265
+ 2. restore the previous deployment and Langfuse registry;
266
+ 3. disable the incorrect OneUptime mapping/reporter;
267
+ 4. remove only the exact API2 ACL/persona/model links introduced by the change,
268
+ using captured before/after rows; and
269
+ 5. preserve the tenant PostgreSQL database and historical traces for audit.
270
+
271
+ Every manual database operation must record environment, target database, query
272
+ checksum, row counts before/after, transaction result, UTC time, operator, and
273
+ reviewer. Rotate any credential exposed in chat or logs.
274
+
275
+ ## Gotchas / known issues
276
+
277
+ - `Core.RecordScripts.id` drifts; `/users/me = 21` is evidence from one
278
+ environment, not a constant.
279
+ - Core and client MySQL databases share a host in non-prod but are physically
280
+ split in production. A cross-database query that worked in beta can be
281
+ impossible in production.
282
+ - Talos PostgreSQL and API2 MySQL are separate. Fixing a Talos tenant row cannot
283
+ repair a missing API2 script/persona ACL, and vice versa.
284
+ - A fresh HTTP 200 run does not prove tool success; inspect SSE termination and
285
+ persisted tool messages.
286
+ - A cached graph must authorize MCP actions from the live per-run runtime
287
+ context. A released/stale run reference makes a newly discovered action fail.
288
+ - Multiple worker generations on one Redis queue produce revision-dependent,
289
+ seemingly client-dependent failures.
290
+
291
+ ## Change history
292
+
293
+ - 2026-08-28 — Captured the Compass USA and NYC Health & Hospitals TOGa Supply
294
+ onboarding workflow, including the API2-MySQL versus Talos-PostgreSQL
295
+ boundary, manifest-driven provisioning, shared user-bearer MCP, Bedrock,
296
+ tenant-scoped Langfuse, OneUptime, concurrent streaming validation, and the
297
+ stale-worker failure mode. (akhokhani)
@@ -27,6 +27,7 @@ _Auto-generated by `knowledge.js index`. Do not hand-edit._
27
27
  - **toga2-view** (TOGa View Frontend) — 12 doc(s) → [2.0/apps/toga2-view/INDEX.md](2.0/apps/toga2-view/INDEX.md)
28
28
  - **toga2-hub** (TOGa Hub) — 2 doc(s) → [2.0/apps/toga2-hub/INDEX.md](2.0/apps/toga2-hub/INDEX.md)
29
29
  - **talos** (TOGa IQ) — 8 doc(s) → [2.0/apps/talos/INDEX.md](2.0/apps/talos/INDEX.md)
30
+ - **talos-backend** (TOGa IQ Backend) — 1 doc(s) → [2.0/apps/talos-backend/INDEX.md](2.0/apps/talos-backend/INDEX.md)
30
31
  - **voice-to-voice** (TOGa Voice) — 4 doc(s) → [2.0/apps/voice-to-voice/INDEX.md](2.0/apps/voice-to-voice/INDEX.md)
31
32
  - **ai-bdr** (AI-BDR) — 13 doc(s) → [2.0/apps/ai-bdr/INDEX.md](2.0/apps/ai-bdr/INDEX.md)
32
33
  - **toga2-commerce** (TOGa Commerce) — 20 doc(s) → [2.0/apps/toga2-commerce/INDEX.md](2.0/apps/toga2-commerce/INDEX.md)
@@ -14,12 +14,13 @@ apps:
14
14
  - dbchanges2
15
15
  - library
16
16
  - test
17
+ - talos-backend
17
18
  project: _Underscore
18
19
  client: compass-usa
19
20
  type: profile
20
21
  status: active
21
- updated: 2026-08-27
22
- owners: [jcardinal, bala, tcox, apeterson, dfranks]
22
+ updated: 2026-08-28
23
+ owners: [jcardinal, bala, tcox, apeterson, dfranks, akhokhani]
23
24
  files: []
24
25
  related:
25
26
  - ../../2.0/apps/_underscore/features/sales-order-po-number-sourcing.md
@@ -11,12 +11,13 @@ apps:
11
11
  - worker2
12
12
  - worker
13
13
  - library
14
+ - talos-backend
14
15
  project: _Underscore
15
16
  client: nychh
16
17
  type: profile
17
18
  status: active
18
19
  updated: 2026-08-28
19
- owners: ["jcardinal", "apeterson", "bala"]
20
+ owners: ["jcardinal", "apeterson", "bala", "akhokhani"]
20
21
  files:
21
22
  - dbchanges2/Client_Nychh/2026-08-18 - InventoryUnitsItemColumns.sql
22
23
  - dbchanges2/Client_Nychh/2026-08-24 - FixInventoryGroupingsUnitsTopologyOverrideIds.sql
@@ -147,6 +147,14 @@
147
147
  "role": "app",
148
148
  "dependsOn": []
149
149
  },
150
+ {
151
+ "repo": "talos-backend",
152
+ "project": "TOGa IQ Backend",
153
+ "framework": "2.0",
154
+ "role": "app",
155
+ "dependsOn": [],
156
+ "language": "python"
157
+ },
150
158
  {
151
159
  "repo": "test",
152
160
  "project": "Test",
@@ -243,4 +251,4 @@
243
251
  "role": "app",
244
252
  "dependsOn": []
245
253
  }
246
- ]
254
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.689",
3
+ "version": "1.0.690",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",