Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1755 lines (1692 loc) · 65.5 KB
/
Copy pathopenapi.yaml
File metadata and controls
1755 lines (1692 loc) · 65.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: Dashanan Memory Orchestration API
version: 1.0.0
summary: >-
Context-assembly and memory-write surface for the Dashanan 8-zone dynamic
memory orchestration engine. Sidecar (Shape B) wire contract per HLD-20260917-01
ADR-004; the in-process SDK facade (Shape A) bypasses this wire entirely.
description: >-
Traceability: every operation below carries a `# FR-NNN` comment tying it to
HLD-20260917-01 Section 7 (endpoint inventory) and the FR numbering established
there (FR-001..FR-008 = the eight zones, FR-009 = orchestrator, FR-010 =
provenance obligation, FR-011 = pluggable storage adapters, FR-012 =
scoring/rotation configurability, FR-013 = conflict-detection sweep,
originated as OAQ-14 and formally adopted as FR-013 in SRS.md v1.0.6,
REQUIRED scope since Zone 3/5 writes cannot satisfy NFR-011 without it).
NFR references trace to HLD Section 9.
x-hld-source: docs/phase-1-architecture/HLD.md#section-7-interface-contracts-and-endpoint-inventory-input-to-phase-15
# Ratified via Phase 8 IR.5 Pre-Implementation Alignment Consensus Gate
# (docs/phase-8-alignment/ir5_alignment_verdict.json, 2026-09-17); narrower-scope
# re-confirmation (story-patch verification), not a standalone Phase 1.5 API
# contract re-review.
x-consensus-gate-status: APPROVED
license:
name: Proprietary
servers:
- url: https://{tenant_host}/v1
description: >-
Shape B sidecar, versioned path segment. `/v1/` is the sole stable
versioning mechanism (ADR-004 consequence: two surfaces, gRPC .proto
package `dashanan.v1` and this generated REST gateway, cannot drift
because both are generated from the same source contract). A breaking
change ships as `/v2/` behind a new deployment, never as a mutation of
`/v1/`; additive fields follow the same FULL-compatibility rule as the
event contracts (Section 7.6).
variables:
tenant_host:
default: api.dashanan.example.com
security:
- bearerAuth: []
tags:
- name: context
description: Synchronous read path (FR-009, FR-006 retrieval fan-out)
- name: memory
description: Asynchronous-accepted write path (FR-009, FR-010, FR-013)
- name: items
description: Per-item read/update/delete surface spanning all zones (FR-009)
- name: zones
description: >-
Zone administration, scope admin:zones (FR-012, NFR-009). `ZoneId` is a
fixed global enum (the eight zone kinds), not a tenant identifier — every
operation under this tag is implicitly scoped to the CALLER'S OWN JWT
`tenant_id` claim (ADR-013), never cross-tenant. A zone admin read
returns only that tenant's items/config/stats for the named zone; there
is no way, via any `admin:zones`-scoped operation, to view another
tenant's zone data. This mirrors the `/tenants/{tenant_id}` invariant
(tenant_id is JWT-authoritative) with no path-level tenant_id exception.
- name: tenants
description: Tenancy and DPDP control plane, scope admin:tenants (NFR-006)
- name: operations
description: Liveness, readiness, metrics (NFR-002 deployment operability)
paths:
# FR-009 (orchestrator: context assembly), FR-006 (Zone 6 fan-out), FR-007
# (provenance travels with every hit). POST form is primary per HLD 7.1:
# the query embedding exceeds practical URL length and query text is
# frequently PII that must not land in access/proxy logs.
/context/assemble:
post:
operationId: assembleContext
tags: [context]
summary: Assemble a budget-fitted, provenance-carrying context slice
description: >-
FR-009, FR-006, FR-007. Safe and idempotent in semantics; cacheable via
response Cache-Control. See NFR-004 read-path latency targets (Section 9)
— those targets are `[ASSUMED]` pending OAQ-13 confirmation and MUST be
reconfirmed before this contract is finalized past DRAFT.
security:
- bearerAuth: [context:read]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AssembleContextRequest'
responses:
'200':
description: Context assembled (possibly degraded; see `degraded` field)
content:
application/json:
schema:
$ref: '#/components/schemas/ContextAssembly'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'410':
$ref: '#/components/responses/StaleCursor'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'429':
$ref: '#/components/responses/RateLimited'
'503':
$ref: '#/components/responses/ServiceDegraded'
# FR-009. Simple form for q-only calls (debug, curl, simple hosts) —
# exists only because neither URL-length nor PII-in-logs reason applies
# to a bare `q` string.
get:
operationId: assembleContextSimple
tags: [context]
summary: Assemble context from a plain-text query (debug / simple hosts)
description: FR-009. Equivalent to assembleContext with only `task` and defaults set.
security:
- bearerAuth: [context:read]
parameters:
- name: session_id
in: query
required: true
schema: { type: string }
- name: q
in: query
required: true
schema: { type: string, maxLength: 2000 }
- name: token_budget
in: query
required: true
schema: { type: integer, minimum: 1, maximum: 262144 }
responses:
'200':
description: Context assembled
content:
application/json:
schema:
$ref: '#/components/schemas/ContextAssembly'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
# FR-006. Advanced/debug: raw retrieval without assembly or budget-fitting.
# Cursor-paginated: this is a genuine list resource, unlike assembleContext's
# single budget-fitted snapshot (api-design-core M1).
/memory/search:
post:
operationId: searchMemory
tags: [context]
summary: Raw hybrid retrieval (vector + lexical, RRF-fused), no budget-fitting
description: FR-006. Advanced/debug surface; bypasses context-assembly scoring.
security:
- bearerAuth: [context:read]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SearchMemoryRequest'
responses:
'200':
description: Ranked candidate list
content:
application/json:
schema:
$ref: '#/components/schemas/SearchMemoryResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'410':
$ref: '#/components/responses/StaleCursor'
# FR-009 (all zones, uniform item envelope), FR-012 (score terms attached).
/items/{item_id}:
parameters:
- $ref: '#/components/parameters/ItemId'
get:
operationId: getItem
tags: [items]
summary: Fetch one item with its current score terms
description: FR-009, FR-012.
security:
- bearerAuth: [context:read]
responses:
'200':
description: Item found
content:
application/json:
schema:
$ref: '#/components/schemas/MemoryItem'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
# FR-010. Never mutates in place: appends a new provenance record and
# supersedes, per Section 3.6 (attribute-level provenance) and Section 3.8
# (append-only Zone 7, no UPDATE grant for any service role).
patch:
operationId: updateItem
tags: [items]
summary: Partial update (appends provenance, supersedes — never in-place)
description: FR-010, FR-013 (a Zone 3/5-targeting update re-enters the conflict-detection sweep).
security:
- bearerAuth: [memory:write]
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateItemRequest'
responses:
'202':
description: Update accepted; new provenance record chained
content:
application/json:
schema:
$ref: '#/components/schemas/WriteReceipt'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/IdempotencyConflict'
'422':
$ref: '#/components/responses/UnprocessableEntity'
# FR-009. Soft delete + tombstone propagation to Zone 6 (Section 3.7:
# Zone 6 is fully rebuildable, so tombstoning there is a projection
# update, not a primary-fact deletion).
delete:
operationId: deleteItem
tags: [items]
summary: Soft delete an item and propagate a tombstone to Zone 6
description: FR-009.
security:
- bearerAuth: [memory:write]
responses:
'202':
description: Delete accepted
content:
application/json:
schema:
$ref: '#/components/schemas/WriteReceipt'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
# FR-010, FR-007. The full Zone 7 record chain for an item — append-only,
# SHA-256 prev_hash chain (Section 3.8, threat control T-2).
/items/{item_id}/provenance:
parameters:
- $ref: '#/components/parameters/ItemId'
get:
operationId: getItemProvenance
tags: [items]
summary: Full provenance record chain for an item
description: FR-010, FR-007.
security:
- bearerAuth: [context:read]
responses:
'200':
description: Provenance chain
content:
application/json:
schema:
$ref: '#/components/schemas/ProvenanceChain'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
# FR-012. Returns all six score terms, weights, weighted score, lifecycle
# state, and predicted threshold-crossing times (Section 3.2, 12A).
# NOTE: the colon suffix is a deliberate Google AIP-136 custom-method path
# (":explain" on the item resource), not an accidental typo or a
# sub-resource segment — same convention as /memory/write:batch below.
/items/{item_id}/score:explain:
parameters:
- $ref: '#/components/parameters/ItemId'
post:
operationId: explainItemScore
tags: [items]
summary: Explain the Memory Score computation for one item
description: FR-012.
security:
- bearerAuth: [context:read]
responses:
'200':
description: Score explanation
content:
application/json:
schema:
$ref: '#/components/schemas/ScoreExplanation'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
# FR-009, FR-010, FR-013 (Zone 3/5-targeting writes enter the conflict
# sweep), and the Zone 3/5 ownership routing of Section 3.4. 202 + write_id;
# Idempotency-Key REQUIRED and bound to a hash of the request body
# (api-design-core anti-pattern 2 — HLD Section 7.2).
/memory/write:
post:
operationId: writeMemory
tags: [memory]
summary: Write one memory item (accepted asynchronously)
description: >-
FR-009, FR-010, FR-013. A write without a resolvable `source_type` is
rejected 422 — FR-010 enforced at the API boundary, before any zone
sees the fact. The accepted write is placed in Zone 1 SYNCHRONOUSLY
before the 202 returns (ADR-002 consequence: read-your-own-write holds
within-session even though cross-zone visibility is eventual).
security:
- bearerAuth: [memory:write]
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/WriteMemoryRequest'
responses:
'202':
description: Write accepted; durability barrier crossed, indexing async
content:
application/json:
schema:
$ref: '#/components/schemas/WriteReceipt'
'207':
description: >-
FR-013 design Section 4.2 step 6 -- Zone 5 (Entity) write
succeeded but one or more Zone 3 (Semantic) edge writes failed
partway through. `WriteReceipt.status` is "partial",
`zone5_written` is true, and `zone3_edges_failed` names the
edges that did not commit. No rollback of the already-durable
Zone 5 write or any already-committed Zone 3 edges is
attempted (fail-fast-plus-honest-partial-reporting; true
cross-zone atomicity is explicitly out of scope, AR1-S3-G3).
content:
application/json:
schema:
$ref: '#/components/schemas/WriteReceipt'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'409':
$ref: '#/components/responses/IdempotencyConflict'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'429':
$ref: '#/components/responses/RateLimited'
'503':
$ref: '#/components/responses/WriteRejectedNotDurable'
# FR-009, FR-010, FR-013. Up to 100 items; per-item receipts; explicit
# partial failure (HLD 7.2).
# NOTE: the colon suffix is a deliberate Google AIP-136 custom-method path
# (":batch" on the collection resource), not an accidental typo or a
# sub-resource segment — same convention as /items/{item_id}/score:explain
# above.
/memory/write:batch:
post:
operationId: writeMemoryBatch
tags: [memory]
summary: Write up to 100 memory items in one call
description: FR-009, FR-010, FR-013.
security:
- bearerAuth: [memory:write]
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [items]
properties:
items:
type: array
minItems: 1
maxItems: 100
items:
$ref: '#/components/schemas/WriteMemoryRequest'
responses:
'202':
description: Batch accepted; per-item receipts, partial failure explicit
content:
application/json:
schema:
type: object
required: [receipts]
properties:
receipts:
type: array
items:
$ref: '#/components/schemas/BatchWriteReceiptItem'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'409':
$ref: '#/components/responses/IdempotencyConflict'
'422':
$ref: '#/components/responses/UnprocessableEntity'
# FR-009, FR-012 (closes doc-gap #5: multi-zone bulk retrieve, symmetric to
# /memory/write:batch above). Up to 100 item_ids; per-item receipts;
# explicit partial failure, same shape as the write-side batch endpoint.
# NOTE: the colon suffix is the same deliberate Google AIP-136 custom-method
# convention as /memory/write:batch and /items/{item_id}/score:explain.
/items:batchGet:
post:
operationId: batchGetItems
tags: [items]
summary: Fetch up to 100 items (with current score terms) in one call
description: >-
FR-009, FR-012. Mirrors /memory/write:batch's partial-failure
contract: a missing or inaccessible item_id does not fail the whole
request, it is reported as a per-item 'not_found' receipt alongside
the successfully retrieved items.
security:
- bearerAuth: [context:read]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [item_ids]
properties:
item_ids:
type: array
minItems: 1
maxItems: 100
items:
type: string
responses:
'200':
description: Batch retrieved; per-item receipts, partial failure explicit
content:
application/json:
schema:
type: object
required: [receipts]
properties:
receipts:
type: array
items:
$ref: '#/components/schemas/BatchGetItemReceiptItem'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
# FR-009. Poll status of an accepted write (accepted / indexed / failed).
/writes/{write_id}:
get:
operationId: getWriteStatus
tags: [memory]
summary: Poll the status of an accepted write
description: FR-009.
security:
- bearerAuth: [memory:write]
parameters:
- name: write_id
in: path
required: true
schema: { type: string, format: uuid }
responses:
'200':
description: Write status
content:
application/json:
schema:
$ref: '#/components/schemas/WriteStatus'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
# FR-012, NFR-009: weights/thresholds/adapter bindings are per-deployment
# configuration, never compiled-in constants.
/zones:
get:
operationId: listZones
tags: [zones]
summary: All eight zones — health, item count, capacity, adapter, last sweep
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
responses:
'200':
description: Zone summaries
content:
application/json:
schema:
type: object
properties:
zones:
type: array
items:
$ref: '#/components/schemas/ZoneSummary'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
/zones/{zone}:
parameters:
- $ref: '#/components/parameters/ZoneName'
get:
operationId: getZoneDetail
tags: [zones]
summary: Zone detail and rotation statistics
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
responses:
'200':
description: Zone detail
content:
application/json:
schema:
$ref: '#/components/schemas/ZoneDetail'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
/zones/{zone}/config:
parameters:
- $ref: '#/components/parameters/ZoneName'
get:
operationId: getZoneConfig
tags: [zones]
summary: Read lambda_zone, thresholds, capacity cap, max age, TTL, adapter binding
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
responses:
'200':
description: Zone configuration
content:
application/json:
schema:
$ref: '#/components/schemas/ZoneConfig'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
put:
operationId: putZoneConfig
tags: [zones]
summary: Update zone configuration (Strategy pattern; no compiled-in constants)
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ZoneConfig'
responses:
'200':
description: Configuration updated
content:
application/json:
schema:
$ref: '#/components/schemas/ZoneConfig'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/UnprocessableEntity'
# FR-012. Force a rotation sweep. O(k log N) by construction (Section 12C,
# threat control D-2).
/zones/{zone}/sweep:
parameters:
- $ref: '#/components/parameters/ZoneName'
post:
operationId: forceZoneSweep
tags: [zones]
summary: Force a rotation sweep for this zone
description: FR-012.
security:
- bearerAuth: [admin:zones]
responses:
'202':
description: Sweep queued
content:
application/json:
schema:
$ref: '#/components/schemas/JobAccepted'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
# FR-009, FR-002 (Episodic zone's own cursor-pagination rule generalized to
# every zone's admin browse per api-design-core M1: offset pagination is
# forbidden at the item counts in Section 12D).
/zones/{zone}/items:
parameters:
- $ref: '#/components/parameters/ZoneName'
get:
operationId: listZoneItems
tags: [zones]
summary: Cursor-paginated admin browse of a zone's items
description: FR-009, FR-002.
security:
- bearerAuth: [admin:zones]
parameters:
- name: cursor
in: query
schema: { type: string }
- name: page_size
in: query
schema: { type: integer, minimum: 1, maximum: 500, default: 50 }
responses:
'200':
description: Page of zone items
content:
application/json:
schema:
$ref: '#/components/schemas/ZoneItemsPage'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
# FR-006. Zone 6 is fully rebuildable by design (Section 3.7).
/zones/{zone}/reindex:
parameters:
- $ref: '#/components/parameters/ZoneName'
post:
operationId: reindexZone
tags: [zones]
summary: Rebuild this zone's Zone 6 (vector + lexical) projection
description: FR-006.
security:
- bearerAuth: [admin:zones]
responses:
'202':
description: Reindex queued
content:
application/json:
schema:
$ref: '#/components/schemas/JobAccepted'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
# FR-012, NFR-009. w1..w6 + the three thresholds — per-deployment, never
# compiled in.
/config/scoring:
get:
operationId: getScoringConfig
tags: [zones]
summary: Read the Memory Score weights and thresholds
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
responses:
'200':
description: Scoring configuration
content:
application/json:
schema:
$ref: '#/components/schemas/ScoringConfig'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
put:
operationId: putScoringConfig
tags: [zones]
summary: Update the Memory Score weights and thresholds
description: FR-012, NFR-009.
security:
- bearerAuth: [admin:zones]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ScoringConfig'
responses:
'200':
description: Scoring configuration updated
content:
application/json:
schema:
$ref: '#/components/schemas/ScoringConfig'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/UnprocessableEntity'
# FR-012. Async admin job status (sweep, reindex, DPDP erasure).
/jobs/{job_id}:
get:
operationId: getJobStatus
tags: [zones]
summary: Async admin job status
description: FR-012.
security:
- bearerAuth: [admin:zones]
parameters:
- name: job_id
in: path
required: true
schema: { type: string, format: uuid }
responses:
'200':
description: Job status
content:
application/json:
schema:
$ref: '#/components/schemas/JobStatus'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
# NFR-006. Provisions physical partitions (ADR-013 hard-partition isolation).
/tenants:
post:
operationId: createTenant
tags: [tenants]
summary: Provision a tenant and its physical partitions
description: NFR-006, ADR-013.
security:
- bearerAuth: [admin:tenants]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTenantRequest'
responses:
'201':
description: Tenant provisioned
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/UnprocessableEntity'
get:
operationId: listTenants
tags: [tenants]
summary: List provisioned tenants
description: NFR-006.
security:
- bearerAuth: [admin:tenants]
parameters:
- name: cursor
in: query
schema: { type: string }
- name: page_size
in: query
schema: { type: integer, minimum: 1, maximum: 500, default: 50 }
responses:
'200':
description: Page of tenants
content:
application/json:
schema:
type: object
required: [items]
properties:
items:
type: array
items:
$ref: '#/components/schemas/Tenant'
next_cursor:
type: string
nullable: true
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
# Control-plane scope-boundary invariant (resolves api-testing-review.md
# BOLA-9 / integration-testing-plan.md gap-table row): `admin:tenants` is a
# PLATFORM-LEVEL scope, not per-tenant-restricted — it is issued only to
# the platform operator, never to a tenant's own service account. The
# `tenant_id` path parameter here is therefore the sole endpoint family
# where tenant scoping is NOT purely JWT-derived (every other endpoint in
# this API takes tenant_id only from the verified JWT claim, ADR-013). The
# JWT's own `tenant_id` claim (present on every bearer token, including a
# platform-operator token) remains authoritative for AUTHENTICATION identity;
# the path `tenant_id` selects WHICH tenant's control-plane record is being
# operated on. Invariant: a caller presenting a token scoped to
# `admin:tenants` but whose `aud`/issuer marks it as a tenant-scoped (not
# platform-operator) credential MUST have its JWT `tenant_id` claim match
# the path `tenant_id`, or the request is rejected 403 (never 404 — the
# caller is authenticated and scoped, just not authorized for this tenant)
# with `error.code: TENANT_SCOPE_MISMATCH`. A true platform-operator token
# is exempt from this match check by design and may address any tenant_id.
/tenants/{tenant_id}:
parameters:
- name: tenant_id
in: path
required: true
schema: { type: string }
description: >-
Target tenant's identifier. This is the only path in the API where
`tenant_id` appears outside the JWT. The JWT's `tenant_id` claim is
always authoritative for the caller's own identity; for a
tenant-scoped `admin:tenants` credential, this path value MUST
equal the JWT's `tenant_id` claim or the request is rejected with
403 `TENANT_SCOPE_MISMATCH` (see the operation descriptions below
and the `Forbidden` response). A platform-operator `admin:tenants`
credential is exempt and may target any tenant_id.
get:
operationId: getTenant
tags: [tenants]
summary: Tenant config, including embedding_residency (ADR-015)
description: >-
NFR-006. Path `tenant_id` must equal the JWT's own `tenant_id` claim
unless the caller holds a platform-operator `admin:tenants`
credential; on mismatch this returns 403 with
`error.code: TENANT_SCOPE_MISMATCH`, never 404 (see Forbidden below).
security:
- bearerAuth: [admin:tenants]
responses:
'200':
description: Tenant
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
description: >-
Credential valid but scope insufficient, OR path `tenant_id` does
not match the JWT's own `tenant_id` claim for a tenant-scoped
`admin:tenants` credential (`TENANT_SCOPE_MISMATCH`) — the JWT
claim is authoritative, the path value must match it.
content:
application/json:
schema: { $ref: '#/components/schemas/ErrorResponse' }
examples:
tenant_scope_mismatch:
summary: Path tenant_id does not match the JWT tenant_id claim
value:
success: false
data: null
error:
code: TENANT_SCOPE_MISMATCH
message: You are not authorized to access this tenant.
trace_id: '4b1e7e2a-...-c9d1'
timestamp: '2026-09-17T10:00:00Z'
'404':
$ref: '#/components/responses/NotFound'
patch:
operationId: updateTenant
tags: [tenants]
summary: Update tenant config
description: >-
NFR-006. Path `tenant_id` must equal the JWT's own `tenant_id` claim
unless the caller holds a platform-operator `admin:tenants`
credential; on mismatch this returns 403 `TENANT_SCOPE_MISMATCH`.
security:
- bearerAuth: [admin:tenants]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateTenantRequest'
responses:
'200':
description: Tenant updated
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/UnprocessableEntity'
delete:
operationId: deleteTenant
tags: [tenants]
summary: Deprovision a tenant
description: >-
NFR-006. Path `tenant_id` must equal the JWT's own `tenant_id` claim
unless the caller holds a platform-operator `admin:tenants`
credential; on mismatch this returns 403 `TENANT_SCOPE_MISMATCH`.
security:
- bearerAuth: [admin:tenants]
responses:
'202':
description: Deprovisioning accepted
content:
application/json:
schema:
$ref: '#/components/schemas/JobAccepted'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
# NFR-006 DPDP-2/3. Crypto-shredding erasure cascade across all 8 zones,
# the vector index, the lexical index and Zone 8 archives (OAQ-10: crypto-
# shredding-as-erasure requires legal confirmation; the endpoint contract
# is stable regardless of that confirmation's outcome).
/tenants/{tenant_id}/subjects/{subject_id}:
parameters:
- name: tenant_id
in: path
required: true
schema: { type: string }
- name: subject_id
in: path
required: true
schema: { type: string }
delete:
operationId: eraseSubject
tags: [tenants]
summary: DPDP erasure cascade for one data subject
description: NFR-006 (DPDP-2, DPDP-3). Cascades across all 8 zones, both retrieval indices, and Zone 8 archives via crypto-shredding.
security:
- bearerAuth: [admin:tenants]
responses:
'202':
description: Erasure cascade accepted
content:
application/json:
schema:
$ref: '#/components/schemas/JobAccepted'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
# NFR-006 DPDP data-portability.
/tenants/{tenant_id}/subjects/{subject_id}/export:
parameters:
- name: tenant_id
in: path
required: true
schema: { type: string }
- name: subject_id
in: path
required: true
schema: { type: string }
get:
operationId: exportSubjectData
tags: [tenants]
summary: DPDP data-portability export for one data subject
description: NFR-006.
security:
- bearerAuth: [admin:tenants]
responses:
'200':
description: Export bundle (synchronous for small subjects; 202 for large ones)
content:
application/json:
schema:
$ref: '#/components/schemas/SubjectExportBundle'
'202':
description: Export queued (large subject)
content:
application/json:
schema:
$ref: '#/components/schemas/JobAccepted'