pdt 0.3.5

Asset store API with relation graphs, tagging, full-text search, multi-instance SQLite tenancy, OIDC auth and Cedar authorization
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
openapi: 3.0.3
info:
  title: Platform Data Toolkit (PDT) API
  description: |
    PDT is a centralized API server that serves as an enterprise knowledge silo for company-specific concepts, documents, and their relationships.

    ## Features

    - **Knowledge Asset Management**: Store and manage knowledge assets with rich metadata
    - **Tag-Based Classification**: Multi-dimensional tagging including asset type, business domain, language, etc.
    - **Graph-Based Relationships**: Define and traverse relationships between assets
    - **Concept Collections**: Organize assets into named collections
    - **Search & Discovery**: Full-text search and tag-based filtering
    - **Audit Logging**: Track all changes with user attribution
  version: 1.0.0
  contact:
    name: PDT Team
  license:
    name: MIT OR Apache-2.0

servers:
  - url: http://localhost:8080
    description: Local development server
  - url: https://api.pdt.company.com
    description: Production server

paths:
  /health:
    get:
      summary: Health check
      description: Check if the PDT service is running and healthy
      operationId: healthCheck
      responses:
        '200':
          description: Service is healthy
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "ok"
                  timestamp:
                    type: string
                    format: date-time

  /api/assets:
    post:
      summary: Create a new asset
      description: Create a new knowledge asset with tags and metadata
      operationId: createAsset
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAssetRequest'
      responses:
        '201':
          description: Asset created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
        '400':
          description: Invalid request data
        '500':
          description: Internal server error
    get:
      summary: List assets
      description: Retrieve a paginated list of assets with optional filtering
      operationId: listAssets
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of assets to return
        - name: cursor
          in: query
          schema:
            type: string
          description: Cursor for pagination
        - name: asset_type
          in: query
          schema:
            type: string
            enum: [document, concept, idea, data_entity, reference]
          description: Filter by asset type tag value
      responses:
        '200':
          description: List of assets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAssetResponse'

  /api/assets/{id}:
    get:
      summary: Get asset by ID
      description: Retrieve a specific asset by its ID
      operationId: getAsset
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
      responses:
        '200':
          description: Asset found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
        '404':
          description: Asset not found
    put:
      summary: Update asset
      description: Update an existing asset's title, content, or metadata
      operationId: updateAsset
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAssetRequest'
      responses:
        '200':
          description: Asset updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
        '404':
          description: Asset not found
    delete:
      summary: Delete asset (soft delete)
      description: Soft delete an asset (marks as deleted but keeps in database)
      operationId: deleteAsset
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
      responses:
        '204':
          description: Asset deleted successfully
        '404':
          description: Asset not found

  /api/assets/{id}/tags:
    post:
      summary: Add tag to asset
      description: Add a classification tag to an existing asset
      operationId: addAssetTag
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddTagRequest'
      responses:
        '200':
          description: Tag added successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
        '404':
          description: Asset not found

  /api/assets/{id}/tags/{tag_id}:
    delete:
      summary: Remove tag from asset
      description: Remove a specific tag from an asset
      operationId: removeAssetTag
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
        - name: tag_id
          in: path
          required: true
          schema:
            type: string
          description: Tag ID
      responses:
        '200':
          description: Tag removed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
        '404':
          description: Asset or tag not found

  /api/relations:
    post:
      summary: Create relation
      description: Create a relationship between two assets
      operationId: createRelation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRelationRequest'
      responses:
        '201':
          description: Relation created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Relation'
        '400':
          description: Invalid request data
        '404':
          description: One or both assets not found

  /api/relations/{id}:
    get:
      summary: Get relation by ID
      description: Retrieve a specific relation by its ID
      operationId: getRelation
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Relation ID
      responses:
        '200':
          description: Relation found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Relation'
        '404':
          description: Relation not found
    delete:
      summary: Delete relation
      description: Delete a relationship between assets
      operationId: deleteRelation
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Relation ID
      responses:
        '204':
          description: Relation deleted successfully
        '404':
          description: Relation not found

  /api/assets/{id}/relations:
    get:
      summary: Get asset relations
      description: Get all relations for a specific asset
      operationId: getAssetRelations
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
        - name: direction
          in: query
          schema:
            type: string
            enum: [incoming, outgoing, both]
            default: both
          description: Direction of relations to retrieve
      responses:
        '200':
          description: List of relations
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Relation'

  /api/assets/{id}/graph:
    get:
      summary: Traverse relationship graph
      description: Traverse the relationship graph starting from an asset
      operationId: traverseGraph
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Starting asset ID
        - name: depth
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 5
            default: 2
          description: Maximum traversal depth
        - name: relation_types
          in: query
          schema:
            type: array
            items:
              type: string
              enum: [contains, references, related_to, depends_on, supersedes, complements]
          description: Filter by relation types
      responses:
        '200':
          description: Graph traversal result
          content:
            application/json:
              schema:
                type: object
                properties:
                  nodes:
                    type: array
                    items:
                      $ref: '#/components/schemas/Asset'
                  edges:
                    type: array
                    items:
                      $ref: '#/components/schemas/Relation'

  /api/collections:
    post:
      summary: Create collection
      description: Create a new named collection of assets
      operationId: createCollection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCollectionRequest'
      responses:
        '201':
          description: Collection created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
    get:
      summary: List collections
      description: Retrieve a paginated list of collections
      operationId: listCollections
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of collections to return
        - name: cursor
          in: query
          schema:
            type: string
          description: Cursor for pagination
      responses:
        '200':
          description: List of collections
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCollectionResponse'

  /api/collections/{id}:
    get:
      summary: Get collection by ID
      description: Retrieve a specific collection by its ID
      operationId: getCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Collection ID
      responses:
        '200':
          description: Collection found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '404':
          description: Collection not found
    put:
      summary: Update collection
      description: Update a collection's name or description
      operationId: updateCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Collection ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCollectionRequest'
      responses:
        '200':
          description: Collection updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '404':
          description: Collection not found
    delete:
      summary: Delete collection
      description: Delete a collection and remove all asset associations
      operationId: deleteCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Collection ID
      responses:
        '204':
          description: Collection deleted successfully
        '404':
          description: Collection not found

  /api/collections/{id}/assets:
    post:
      summary: Add asset to collection
      description: Add an existing asset to a collection
      operationId: addAssetToCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Collection ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddAssetToCollectionRequest'
      responses:
        '200':
          description: Asset added to collection successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '404':
          description: Collection or asset not found

  /api/collections/{id}/assets/{asset_id}:
    delete:
      summary: Remove asset from collection
      description: Remove an asset from a collection
      operationId: removeAssetFromCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Collection ID
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
      responses:
        '200':
          description: Asset removed from collection successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '404':
          description: Collection or asset not found

  /api/search:
    get:
      summary: Search assets (compact by default)
      description: |
        Full-text search assets with tag-based filtering.

        **Default behavior (full_content=false)**: Returns compact SearchResult objects
        containing only id, title, snippet (first ~200 chars, markdown-stripped),
        tags (category + value only), and updated_at. This is efficient for listing
        and discovery — use it to find asset IDs, then call GET /api/assets/{id}
        to retrieve full content when needed.

        **With full_content=true**: Returns full Asset objects with complete content,
        metadata, and full tag details (id, added_by, added_at). Use sparingly —
        this can flood context windows and waste bandwidth.
      operationId: searchAssets
      parameters:
        - name: q
          in: query
          schema:
            type: string
          description: Full-text search query
        - name: tags
          in: query
          schema:
            type: array
            items:
              type: string
          style: form
          explode: false
          description: Tag filters in format "category:value" (e.g., "asset_type:document")
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of results to return
        - name: cursor
          in: query
          schema:
            type: string
          description: Cursor for pagination
        - name: full_content
          in: query
          schema:
            type: boolean
            default: false
          description: |
            When true, return full Asset objects with complete content.
            Default: false (returns compact SearchResult with snippet).
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                description: |
                  By default returns compact SearchResult objects (id, title, snippet, tags, updated_at).
                  When full_content=true, returns full Asset objects.
                oneOf:
                  - $ref: '#/components/schemas/PaginatedSearchResultResponse'
                  - $ref: '#/components/schemas/PaginatedAssetResponse'

  /api/audit:
    get:
      summary: List audit entries
      description: Retrieve audit log entries for tracking changes
      operationId: listAuditEntries
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of entries to return
        - name: cursor
          in: query
          schema:
            type: string
          description: Cursor for pagination
        - name: asset_id
          in: query
          schema:
            type: string
          description: Filter by asset ID
        - name: user_id
          in: query
          schema:
            type: string
          description: Filter by user ID
        - name: action
          in: query
          schema:
            type: string
            enum: [create, update, delete, tag_add, tag_remove]
          description: Filter by action type
      responses:
        '200':
          description: List of audit entries
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAuditResponse'

  /api/assets/{id}/history:
    get:
      summary: Get asset change history
      description: Retrieve the change history for a specific asset
      operationId: getAssetHistory
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Asset ID
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of history entries to return
        - name: cursor
          in: query
          schema:
            type: string
          description: Cursor for pagination
      responses:
        '200':
          description: Asset change history
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAuditResponse'

components:
  schemas:
    Asset:
      type: object
      required:
        - id
        - title
        - created_at
        - updated_at
        - created_by
      properties:
        id:
          type: string
          description: Unique asset identifier
          example: "507f1f77bcf86cd799439011"
        title:
          type: string
          description: Asset title
          example: "User Authentication Design Document"
        content:
          type: string
          description: Asset content (markdown, text, etc.)
          example: "# User Authentication\n\nThis document describes..."
        tags:
          type: array
          items:
            $ref: '#/components/schemas/Tag'
          description: Classification tags
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata as key-value pairs
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
        created_by:
          type: string
          description: User who created the asset
          example: "john.doe@company.com"
        deleted_at:
          type: string
          format: date-time
          description: Soft delete timestamp (null if not deleted)

    CreateAssetRequest:
      type: object
      required:
        - title
      properties:
        title:
          type: string
          description: Asset title
          example: "User Authentication Design Document"
        content:
          type: string
          description: Asset content
          example: "# User Authentication\n\nThis document describes..."
        tags:
          type: array
          items:
            $ref: '#/components/schemas/AddTagRequest'
          description: Initial classification tags (should include asset_type)
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata

    UpdateAssetRequest:
      type: object
      properties:
        title:
          type: string
          description: New asset title
        content:
          type: string
          description: New asset content
        metadata:
          type: object
          additionalProperties: true
          description: Updated metadata

    Tag:
      type: object
      required:
        - id
        - category
        - value
        - added_by
        - added_at
      properties:
        id:
          type: string
          description: Unique tag identifier
        category:
          type: string
          description: |
            Tag category (free-form string). Common categories include:
            - `type` - Asset type (document, idea, requirement, bug, task)
            - `status` - Status (draft, review, approved, archived)
            - `domain` - Business domain (backend, frontend, infra)
            - `lang` - Language (en, fa)
            - `priority` - Priority (high, medium, low)
            - `scope` - Feature/component scope
          example: "type"
          pattern: "^[a-zA-Z0-9_/-]+$"
          maxLength: 64
        value:
          type: string
          description: Tag value
          example: "document"
        added_by:
          type: string
          description: User who added the tag
        added_at:
          type: string
          format: date-time
          description: When the tag was added

    AddTagRequest:
      type: object
      required:
        - category
        - value
      properties:
        category:
          type: string
          description: |
            Tag category (free-form string). Common categories include:
            - `type` - Asset type (document, idea, requirement, bug, task)
            - `status` - Status (draft, review, approved, archived)
            - `domain` - Business domain (backend, frontend, infra)
            - `lang` - Language (en, fa)
            - `priority` - Priority (high, medium, low)
            - `scope` - Feature/component scope
          example: "type"
          pattern: "^[a-zA-Z0-9_/-]+$"
          maxLength: 64
        value:
          type: string
          description: Tag value
          example: "document"
          maxLength: 256

    Relation:
      type: object
      required:
        - id
        - from_asset_id
        - to_asset_id
        - relation_type
        - created_at
        - created_by
      properties:
        id:
          type: string
          description: Unique relation identifier
        from_asset_id:
          type: string
          description: Source asset ID
        to_asset_id:
          type: string
          description: Target asset ID
        relation_type:
          $ref: '#/components/schemas/RelationType'
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        created_by:
          type: string
          description: User who created the relation

    RelationType:
      type: string
      enum:
        - contains
        - references
        - related_to
        - depends_on
        - supersedes
        - complements
      description: |
        Types of relationships between assets:

        - `contains`: Asset includes other assets
        - `references`: Asset cites or links to another
        - `related_to`: General associations between assets
        - `depends_on`: Required relationships for asset validity
        - `supersedes`: Asset replaces or updates another
        - `complements`: Assets enhance each other's value

    CreateRelationRequest:
      type: object
      required:
        - from_asset_id
        - to_asset_id
        - relation_type
      properties:
        from_asset_id:
          type: string
          description: Source asset ID
        to_asset_id:
          type: string
          description: Target asset ID
        relation_type:
          $ref: '#/components/schemas/RelationType'
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata

    Collection:
      type: object
      required:
        - id
        - name
        - created_at
        - updated_at
        - created_by
      properties:
        id:
          type: string
          description: Unique collection identifier
        name:
          type: string
          description: Collection name
          example: "Authentication Concepts"
        description:
          type: string
          description: Collection description
        tags:
          type: array
          items:
            $ref: '#/components/schemas/Tag'
          description: Collection classification tags
        asset_ids:
          type: array
          items:
            type: string
          description: IDs of assets in this collection
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
        created_by:
          type: string
          description: User who created the collection

    CreateCollectionRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Collection name
          example: "Authentication Concepts"
        description:
          type: string
          description: Collection description
        tags:
          type: array
          items:
            $ref: '#/components/schemas/AddTagRequest'
          description: Initial classification tags

    UpdateCollectionRequest:
      type: object
      properties:
        name:
          type: string
          description: New collection name
        description:
          type: string
          description: New collection description

    AddAssetToCollectionRequest:
      type: object
      required:
        - asset_id
      properties:
        asset_id:
          type: string
          description: Asset ID to add to collection

    AuditEntry:
      type: object
      required:
        - id
        - asset_id
        - action
        - user_id
        - timestamp
      properties:
        id:
          type: string
          description: Unique audit entry identifier
        asset_id:
          type: string
          description: Asset ID that was changed
        action:
          type: string
          enum: [create, update, delete, tag_add, tag_remove]
          description: Type of action performed
        user_id:
          type: string
          description: User who performed the action
        timestamp:
          type: string
          format: date-time
          description: When the action occurred
        details:
          type: object
          additionalProperties: true
          description: Additional action details

    SearchResult:
      type: object
      required:
        - id
        - title
        - updated_at
      properties:
        id:
          type: string
          description: Unique asset identifier
          example: "507f1f77bcf86cd799439011"
        title:
          type: string
          description: Asset title
          example: "User Authentication Design Document"
        snippet:
          type: string
          description: Auto-generated snippet (first 200 chars, markdown-stripped)
          example: "User Authentication This document describes the authentication flow..."
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagSummary'
          description: Compact tags (category + value only)
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp

    TagSummary:
      type: object
      required:
        - category
        - value
      properties:
        category:
          type: string
          description: Tag category
          example: "type"
        value:
          type: string
          description: Tag value
          example: "document"

    PaginatedSearchResultResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/SearchResult'
        next_cursor:
          type: string
          description: Cursor for next page (null if no more pages)
        total:
          type: integer
          description: Total number of results (optional)

    PaginatedAssetResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Asset'
        next_cursor:
          type: string
          description: Cursor for next page (null if no more pages)
        total:
          type: integer
          description: Total number of assets (optional)

    PaginatedCollectionResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Collection'
        next_cursor:
          type: string
          description: Cursor for next page (null if no more pages)
        total:
          type: integer
          description: Total number of collections (optional)

    PaginatedAuditResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AuditEntry'
        next_cursor:
          type: string
          description: Cursor for next page (null if no more pages)
        total:
          type: integer
          description: Total number of audit entries (optional)

  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication (if implemented)

# Optional: Add security requirements if authentication is implemented
# security:
#   - ApiKeyAuth: []