@okf/ootils 1.37.0 → 1.38.0

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.
@@ -597,7 +597,7 @@ declare namespace BASE_BULLMQ_CONFIG {
597
597
  }
598
598
  export { workerConfig_7 as workerConfig };
599
599
  }
600
- namespace ANNOS_ELASTIC_SYNC_QUEUE {
600
+ namespace AI_AUTO_ANNOTATE_CHUNK_QUEUE {
601
601
  let id_8: string;
602
602
  export { id_8 as id };
603
603
  export namespace queueConfig_8 {
@@ -637,7 +637,7 @@ declare namespace BASE_BULLMQ_CONFIG {
637
637
  }
638
638
  export { workerConfig_8 as workerConfig };
639
639
  }
640
- namespace CHUNKS_ELASTIC_SYNC_QUEUE {
640
+ namespace ANNOS_ELASTIC_SYNC_QUEUE {
641
641
  let id_9: string;
642
642
  export { id_9 as id };
643
643
  export namespace queueConfig_9 {
@@ -677,7 +677,7 @@ declare namespace BASE_BULLMQ_CONFIG {
677
677
  }
678
678
  export { workerConfig_9 as workerConfig };
679
679
  }
680
- namespace USERS_ELASTIC_SYNC_QUEUE {
680
+ namespace CHUNKS_ELASTIC_SYNC_QUEUE {
681
681
  let id_10: string;
682
682
  export { id_10 as id };
683
683
  export namespace queueConfig_10 {
@@ -717,7 +717,7 @@ declare namespace BASE_BULLMQ_CONFIG {
717
717
  }
718
718
  export { workerConfig_10 as workerConfig };
719
719
  }
720
- namespace CONTENT_ELASTIC_SYNC_QUEUE {
720
+ namespace USERS_ELASTIC_SYNC_QUEUE {
721
721
  let id_11: string;
722
722
  export { id_11 as id };
723
723
  export namespace queueConfig_11 {
@@ -757,7 +757,7 @@ declare namespace BASE_BULLMQ_CONFIG {
757
757
  }
758
758
  export { workerConfig_11 as workerConfig };
759
759
  }
760
- namespace SARVAM_TRANSCRIPTION_QUEUE {
760
+ namespace CONTENT_ELASTIC_SYNC_QUEUE {
761
761
  let id_12: string;
762
762
  export { id_12 as id };
763
763
  export namespace queueConfig_12 {
@@ -797,7 +797,7 @@ declare namespace BASE_BULLMQ_CONFIG {
797
797
  }
798
798
  export { workerConfig_12 as workerConfig };
799
799
  }
800
- namespace INTERCOM_CONVERSATIONS_QUEUE {
800
+ namespace SARVAM_TRANSCRIPTION_QUEUE {
801
801
  let id_13: string;
802
802
  export { id_13 as id };
803
803
  export namespace queueConfig_13 {
@@ -837,7 +837,7 @@ declare namespace BASE_BULLMQ_CONFIG {
837
837
  }
838
838
  export { workerConfig_13 as workerConfig };
839
839
  }
840
- namespace TAG_SYNC_PLAN_QUEUE {
840
+ namespace INTERCOM_CONVERSATIONS_QUEUE {
841
841
  let id_14: string;
842
842
  export { id_14 as id };
843
843
  export namespace queueConfig_14 {
@@ -877,7 +877,7 @@ declare namespace BASE_BULLMQ_CONFIG {
877
877
  }
878
878
  export { workerConfig_14 as workerConfig };
879
879
  }
880
- namespace TAG_SYNC_BATCH_QUEUE {
880
+ namespace TAG_SYNC_PLAN_QUEUE {
881
881
  let id_15: string;
882
882
  export { id_15 as id };
883
883
  export namespace queueConfig_15 {
@@ -917,11 +917,13 @@ declare namespace BASE_BULLMQ_CONFIG {
917
917
  }
918
918
  export { workerConfig_15 as workerConfig };
919
919
  }
920
- namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
920
+ namespace TAG_SYNC_BATCH_QUEUE {
921
921
  let id_16: string;
922
922
  export { id_16 as id };
923
923
  export namespace queueConfig_16 {
924
924
  export namespace defaultJobOptions_16 {
925
+ let attempts_16: number;
926
+ export { attempts_16 as attempts };
925
927
  export namespace backoff_16 {
926
928
  let type_16: string;
927
929
  export { type_16 as type };
@@ -929,8 +931,6 @@ declare namespace BASE_BULLMQ_CONFIG {
929
931
  export { delay_16 as delay };
930
932
  }
931
933
  export { backoff_16 as backoff };
932
- let attempts_16: number;
933
- export { attempts_16 as attempts };
934
934
  let removeOnComplete_16: number;
935
935
  export { removeOnComplete_16 as removeOnComplete };
936
936
  let removeOnFail_16: number;
@@ -957,13 +957,11 @@ declare namespace BASE_BULLMQ_CONFIG {
957
957
  }
958
958
  export { workerConfig_16 as workerConfig };
959
959
  }
960
- namespace REINDEX_QUEUE {
960
+ namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
961
961
  let id_17: string;
962
962
  export { id_17 as id };
963
963
  export namespace queueConfig_17 {
964
964
  export namespace defaultJobOptions_17 {
965
- let attempts_17: number;
966
- export { attempts_17 as attempts };
967
965
  export namespace backoff_17 {
968
966
  let type_17: string;
969
967
  export { type_17 as type };
@@ -971,8 +969,8 @@ declare namespace BASE_BULLMQ_CONFIG {
971
969
  export { delay_17 as delay };
972
970
  }
973
971
  export { backoff_17 as backoff };
974
- let delay_18: number;
975
- export { delay_18 as delay };
972
+ let attempts_17: number;
973
+ export { attempts_17 as attempts };
976
974
  let removeOnComplete_17: number;
977
975
  export { removeOnComplete_17 as removeOnComplete };
978
976
  let removeOnFail_17: number;
@@ -999,6 +997,48 @@ declare namespace BASE_BULLMQ_CONFIG {
999
997
  }
1000
998
  export { workerConfig_17 as workerConfig };
1001
999
  }
1000
+ namespace REINDEX_QUEUE {
1001
+ let id_18: string;
1002
+ export { id_18 as id };
1003
+ export namespace queueConfig_18 {
1004
+ export namespace defaultJobOptions_18 {
1005
+ let attempts_18: number;
1006
+ export { attempts_18 as attempts };
1007
+ export namespace backoff_18 {
1008
+ let type_18: string;
1009
+ export { type_18 as type };
1010
+ let delay_18: number;
1011
+ export { delay_18 as delay };
1012
+ }
1013
+ export { backoff_18 as backoff };
1014
+ let delay_19: number;
1015
+ export { delay_19 as delay };
1016
+ let removeOnComplete_18: number;
1017
+ export { removeOnComplete_18 as removeOnComplete };
1018
+ let removeOnFail_18: number;
1019
+ export { removeOnFail_18 as removeOnFail };
1020
+ }
1021
+ export { defaultJobOptions_18 as defaultJobOptions };
1022
+ export namespace streams_18 {
1023
+ export namespace events_18 {
1024
+ let maxLen_18: number;
1025
+ export { maxLen_18 as maxLen };
1026
+ }
1027
+ export { events_18 as events };
1028
+ }
1029
+ export { streams_18 as streams };
1030
+ }
1031
+ export { queueConfig_18 as queueConfig };
1032
+ export namespace workerConfig_18 {
1033
+ let concurrency_18: number;
1034
+ export { concurrency_18 as concurrency };
1035
+ let lockDuration_18: number;
1036
+ export { lockDuration_18 as lockDuration };
1037
+ let maxStalledCount_18: number;
1038
+ export { maxStalledCount_18 as maxStalledCount };
1039
+ }
1040
+ export { workerConfig_18 as workerConfig };
1041
+ }
1002
1042
  }
1003
1043
 
1004
1044
  interface PlatformContextContentItem {
@@ -1187,7 +1227,7 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1187
1227
  profileTypes: any[];
1188
1228
  pinnedOptions: {
1189
1229
  display: string;
1190
- value: null;
1230
+ value: string;
1191
1231
  }[];
1192
1232
  options?: undefined;
1193
1233
  };
@@ -1477,7 +1517,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1477
1517
  profileTypes: any[];
1478
1518
  pinnedOptions: {
1479
1519
  display: string;
1480
- value: null;
1520
+ value: string;
1481
1521
  }[];
1482
1522
  options?: undefined;
1483
1523
  };
package/dist/browser.d.ts CHANGED
@@ -597,7 +597,7 @@ declare namespace BASE_BULLMQ_CONFIG {
597
597
  }
598
598
  export { workerConfig_7 as workerConfig };
599
599
  }
600
- namespace ANNOS_ELASTIC_SYNC_QUEUE {
600
+ namespace AI_AUTO_ANNOTATE_CHUNK_QUEUE {
601
601
  let id_8: string;
602
602
  export { id_8 as id };
603
603
  export namespace queueConfig_8 {
@@ -637,7 +637,7 @@ declare namespace BASE_BULLMQ_CONFIG {
637
637
  }
638
638
  export { workerConfig_8 as workerConfig };
639
639
  }
640
- namespace CHUNKS_ELASTIC_SYNC_QUEUE {
640
+ namespace ANNOS_ELASTIC_SYNC_QUEUE {
641
641
  let id_9: string;
642
642
  export { id_9 as id };
643
643
  export namespace queueConfig_9 {
@@ -677,7 +677,7 @@ declare namespace BASE_BULLMQ_CONFIG {
677
677
  }
678
678
  export { workerConfig_9 as workerConfig };
679
679
  }
680
- namespace USERS_ELASTIC_SYNC_QUEUE {
680
+ namespace CHUNKS_ELASTIC_SYNC_QUEUE {
681
681
  let id_10: string;
682
682
  export { id_10 as id };
683
683
  export namespace queueConfig_10 {
@@ -717,7 +717,7 @@ declare namespace BASE_BULLMQ_CONFIG {
717
717
  }
718
718
  export { workerConfig_10 as workerConfig };
719
719
  }
720
- namespace CONTENT_ELASTIC_SYNC_QUEUE {
720
+ namespace USERS_ELASTIC_SYNC_QUEUE {
721
721
  let id_11: string;
722
722
  export { id_11 as id };
723
723
  export namespace queueConfig_11 {
@@ -757,7 +757,7 @@ declare namespace BASE_BULLMQ_CONFIG {
757
757
  }
758
758
  export { workerConfig_11 as workerConfig };
759
759
  }
760
- namespace SARVAM_TRANSCRIPTION_QUEUE {
760
+ namespace CONTENT_ELASTIC_SYNC_QUEUE {
761
761
  let id_12: string;
762
762
  export { id_12 as id };
763
763
  export namespace queueConfig_12 {
@@ -797,7 +797,7 @@ declare namespace BASE_BULLMQ_CONFIG {
797
797
  }
798
798
  export { workerConfig_12 as workerConfig };
799
799
  }
800
- namespace INTERCOM_CONVERSATIONS_QUEUE {
800
+ namespace SARVAM_TRANSCRIPTION_QUEUE {
801
801
  let id_13: string;
802
802
  export { id_13 as id };
803
803
  export namespace queueConfig_13 {
@@ -837,7 +837,7 @@ declare namespace BASE_BULLMQ_CONFIG {
837
837
  }
838
838
  export { workerConfig_13 as workerConfig };
839
839
  }
840
- namespace TAG_SYNC_PLAN_QUEUE {
840
+ namespace INTERCOM_CONVERSATIONS_QUEUE {
841
841
  let id_14: string;
842
842
  export { id_14 as id };
843
843
  export namespace queueConfig_14 {
@@ -877,7 +877,7 @@ declare namespace BASE_BULLMQ_CONFIG {
877
877
  }
878
878
  export { workerConfig_14 as workerConfig };
879
879
  }
880
- namespace TAG_SYNC_BATCH_QUEUE {
880
+ namespace TAG_SYNC_PLAN_QUEUE {
881
881
  let id_15: string;
882
882
  export { id_15 as id };
883
883
  export namespace queueConfig_15 {
@@ -917,11 +917,13 @@ declare namespace BASE_BULLMQ_CONFIG {
917
917
  }
918
918
  export { workerConfig_15 as workerConfig };
919
919
  }
920
- namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
920
+ namespace TAG_SYNC_BATCH_QUEUE {
921
921
  let id_16: string;
922
922
  export { id_16 as id };
923
923
  export namespace queueConfig_16 {
924
924
  export namespace defaultJobOptions_16 {
925
+ let attempts_16: number;
926
+ export { attempts_16 as attempts };
925
927
  export namespace backoff_16 {
926
928
  let type_16: string;
927
929
  export { type_16 as type };
@@ -929,8 +931,6 @@ declare namespace BASE_BULLMQ_CONFIG {
929
931
  export { delay_16 as delay };
930
932
  }
931
933
  export { backoff_16 as backoff };
932
- let attempts_16: number;
933
- export { attempts_16 as attempts };
934
934
  let removeOnComplete_16: number;
935
935
  export { removeOnComplete_16 as removeOnComplete };
936
936
  let removeOnFail_16: number;
@@ -957,13 +957,11 @@ declare namespace BASE_BULLMQ_CONFIG {
957
957
  }
958
958
  export { workerConfig_16 as workerConfig };
959
959
  }
960
- namespace REINDEX_QUEUE {
960
+ namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
961
961
  let id_17: string;
962
962
  export { id_17 as id };
963
963
  export namespace queueConfig_17 {
964
964
  export namespace defaultJobOptions_17 {
965
- let attempts_17: number;
966
- export { attempts_17 as attempts };
967
965
  export namespace backoff_17 {
968
966
  let type_17: string;
969
967
  export { type_17 as type };
@@ -971,8 +969,8 @@ declare namespace BASE_BULLMQ_CONFIG {
971
969
  export { delay_17 as delay };
972
970
  }
973
971
  export { backoff_17 as backoff };
974
- let delay_18: number;
975
- export { delay_18 as delay };
972
+ let attempts_17: number;
973
+ export { attempts_17 as attempts };
976
974
  let removeOnComplete_17: number;
977
975
  export { removeOnComplete_17 as removeOnComplete };
978
976
  let removeOnFail_17: number;
@@ -999,6 +997,48 @@ declare namespace BASE_BULLMQ_CONFIG {
999
997
  }
1000
998
  export { workerConfig_17 as workerConfig };
1001
999
  }
1000
+ namespace REINDEX_QUEUE {
1001
+ let id_18: string;
1002
+ export { id_18 as id };
1003
+ export namespace queueConfig_18 {
1004
+ export namespace defaultJobOptions_18 {
1005
+ let attempts_18: number;
1006
+ export { attempts_18 as attempts };
1007
+ export namespace backoff_18 {
1008
+ let type_18: string;
1009
+ export { type_18 as type };
1010
+ let delay_18: number;
1011
+ export { delay_18 as delay };
1012
+ }
1013
+ export { backoff_18 as backoff };
1014
+ let delay_19: number;
1015
+ export { delay_19 as delay };
1016
+ let removeOnComplete_18: number;
1017
+ export { removeOnComplete_18 as removeOnComplete };
1018
+ let removeOnFail_18: number;
1019
+ export { removeOnFail_18 as removeOnFail };
1020
+ }
1021
+ export { defaultJobOptions_18 as defaultJobOptions };
1022
+ export namespace streams_18 {
1023
+ export namespace events_18 {
1024
+ let maxLen_18: number;
1025
+ export { maxLen_18 as maxLen };
1026
+ }
1027
+ export { events_18 as events };
1028
+ }
1029
+ export { streams_18 as streams };
1030
+ }
1031
+ export { queueConfig_18 as queueConfig };
1032
+ export namespace workerConfig_18 {
1033
+ let concurrency_18: number;
1034
+ export { concurrency_18 as concurrency };
1035
+ let lockDuration_18: number;
1036
+ export { lockDuration_18 as lockDuration };
1037
+ let maxStalledCount_18: number;
1038
+ export { maxStalledCount_18 as maxStalledCount };
1039
+ }
1040
+ export { workerConfig_18 as workerConfig };
1041
+ }
1002
1042
  }
1003
1043
 
1004
1044
  interface PlatformContextContentItem {
@@ -1187,7 +1227,7 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1187
1227
  profileTypes: any[];
1188
1228
  pinnedOptions: {
1189
1229
  display: string;
1190
- value: null;
1230
+ value: string;
1191
1231
  }[];
1192
1232
  options?: undefined;
1193
1233
  };
@@ -1477,7 +1517,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1477
1517
  profileTypes: any[];
1478
1518
  pinnedOptions: {
1479
1519
  display: string;
1480
- value: null;
1520
+ value: string;
1481
1521
  }[];
1482
1522
  options?: undefined;
1483
1523
  };
package/dist/browser.js CHANGED
@@ -990,6 +990,15 @@ var BASE_BULLMQ_CONFIG = {
990
990
  }
991
991
  },
992
992
  AI_AUTO_ANNOTATE_QUEUE: {
993
+ // PARENT queue in the per-doc Flow. One job per doc; child jobs (one
994
+ // per chunk) live on AI_AUTO_ANNOTATE_CHUNK_QUEUE. BullMQ Flow fires
995
+ // the parent only after all children settle. Parent job's worker
996
+ // collects children's suggestions, runs ONE doc-level inductive batch
997
+ // dedup, applies merged annotations to editor state, writes the doc.
998
+ //
999
+ // The progress tracker aggregator (calculateSegByAutoAnnotateIdJobs in
1000
+ // okf-sub) filters by this queue's id, so parents = 1 job per doc
1001
+ // matches the existing FE progress counting semantics 1:1.
993
1002
  id: "ai-auto-annotate-queue",
994
1003
  queueConfig: {
995
1004
  defaultJobOptions: {
@@ -1008,14 +1017,70 @@ var BASE_BULLMQ_CONFIG = {
1008
1017
  }
1009
1018
  },
1010
1019
  workerConfig: {
1011
- // Parallel-safe: createTag/createSubTheme catch E11000 on the unique tagId
1012
- // index and re-fetch the existing doc, so concurrent jobs proposing the
1013
- // same tag converge to one. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js.
1014
- // Starting at 10; real ceiling is the LLM provider's rate limit.
1015
- concurrency: 15,
1020
+ // Parallel-safe across docs: per-doc isolation on annotations.tags
1021
+ // rollup (each parent processes a different doc); tenant-level Redis
1022
+ // lock in resolveInductiveBatch serializes inductive dedup across
1023
+ // concurrent parents; createTag/createSubTheme catch E11000 on the
1024
+ // unique tagId index. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js
1025
+ // + ai/dualAgentAnnotation/tools/resolveInductiveBatch.js.
1026
+ concurrency: 5,
1016
1027
  lockDuration: 3e5,
1017
- // 5 minutes lock duration since annotation can be slow
1018
- maxStalledCount: 3
1028
+ // 5 min generous ceiling so heartbeat stutters don't trip stalled detection
1029
+ // With attempts:1 a stalled job has no retry left anyway, but keeping
1030
+ // stalled-count low ensures BullMQ doesn't mis-pickup a job whose
1031
+ // worker is just CPU-busy.
1032
+ maxStalledCount: 1
1033
+ }
1034
+ },
1035
+ AI_AUTO_ANNOTATE_CHUNK_QUEUE: {
1036
+ // CHILDREN queue in the per-doc Flow. One job per (doc, field, chunk).
1037
+ // Each job calls okf-be /internal/getChunkSuggestions for its one chunk
1038
+ // — a small fast call well under App Engine's 60s ceiling regardless
1039
+ // of how large the source doc is. Failure of a single chunk does NOT
1040
+ // kill the parent (children opt in via failParentOnFailure: false) —
1041
+ // the parent's worker handles partial-success aggregation, mirroring
1042
+ // the Promise.allSettled semantic at the BullMQ level.
1043
+ //
1044
+ // The progress tracker IGNORES this queue (the aggregator filters on
1045
+ // AI_AUTO_ANNOTATE_QUEUE.id), so chunk granularity is available in
1046
+ // job state for any future drill-in UI without disrupting today's
1047
+ // doc-level progress UI.
1048
+ id: "ai-auto-annotate-chunk-queue",
1049
+ queueConfig: {
1050
+ defaultJobOptions: {
1051
+ // One try, no retries. A retry would re-fire the dual-agent LLM
1052
+ // chain (annotator + moderator + attribute classifier) for the
1053
+ // same chunk — expensive, and if the first try hit an OpenAI
1054
+ // 429/timeout the retry will likely hit the same condition.
1055
+ // Failed chunks surface to the parent via getFailedChildrenValues
1056
+ // and become a partial-success on the field (the rest still apply).
1057
+ attempts: 1,
1058
+ backoff: {
1059
+ type: "exponential",
1060
+ delay: 5e3
1061
+ },
1062
+ removeOnComplete: 100,
1063
+ // chunks fan out wider; keep a few more
1064
+ removeOnFail: 300
1065
+ },
1066
+ streams: {
1067
+ events: {
1068
+ maxLen: 10
1069
+ }
1070
+ }
1071
+ },
1072
+ workerConfig: {
1073
+ // OpenAI gpt-4.1-mini TPM ceiling is 10M tokens/min. Each chunk
1074
+ // does ~4 LLM calls in series totalling ~22K tokens.
1075
+ // 5 chunks in flight × 4 calls/chunk × 60s / 15s-per-call
1076
+ // ≈ 80 calls/min × 6.5K tokens
1077
+ // ≈ 520K tokens/min sustained → ~5% of TPM ceiling.
1078
+ // Comfortable headroom for variance (long-tail chunks, bigger
1079
+ // taxonomies, mixed-tenant batches).
1080
+ concurrency: 5,
1081
+ lockDuration: 18e4,
1082
+ // 3 min — a single chunk's dual-agent run fits well under
1083
+ maxStalledCount: 1
1019
1084
  }
1020
1085
  },
1021
1086
  ANNOS_ELASTIC_SYNC_QUEUE: {
@@ -2097,7 +2162,7 @@ var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks =
2097
2162
  filterType: "usersType",
2098
2163
  profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
2099
2164
  pinnedOptions: [
2100
- { display: "AI", value: null }
2165
+ { display: "AI", value: "-ai-as-author-" }
2101
2166
  ]
2102
2167
  },
2103
2168
  target: {
package/dist/browser.mjs CHANGED
@@ -921,6 +921,15 @@ var BASE_BULLMQ_CONFIG = {
921
921
  }
922
922
  },
923
923
  AI_AUTO_ANNOTATE_QUEUE: {
924
+ // PARENT queue in the per-doc Flow. One job per doc; child jobs (one
925
+ // per chunk) live on AI_AUTO_ANNOTATE_CHUNK_QUEUE. BullMQ Flow fires
926
+ // the parent only after all children settle. Parent job's worker
927
+ // collects children's suggestions, runs ONE doc-level inductive batch
928
+ // dedup, applies merged annotations to editor state, writes the doc.
929
+ //
930
+ // The progress tracker aggregator (calculateSegByAutoAnnotateIdJobs in
931
+ // okf-sub) filters by this queue's id, so parents = 1 job per doc
932
+ // matches the existing FE progress counting semantics 1:1.
924
933
  id: "ai-auto-annotate-queue",
925
934
  queueConfig: {
926
935
  defaultJobOptions: {
@@ -939,14 +948,70 @@ var BASE_BULLMQ_CONFIG = {
939
948
  }
940
949
  },
941
950
  workerConfig: {
942
- // Parallel-safe: createTag/createSubTheme catch E11000 on the unique tagId
943
- // index and re-fetch the existing doc, so concurrent jobs proposing the
944
- // same tag converge to one. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js.
945
- // Starting at 10; real ceiling is the LLM provider's rate limit.
946
- concurrency: 15,
951
+ // Parallel-safe across docs: per-doc isolation on annotations.tags
952
+ // rollup (each parent processes a different doc); tenant-level Redis
953
+ // lock in resolveInductiveBatch serializes inductive dedup across
954
+ // concurrent parents; createTag/createSubTheme catch E11000 on the
955
+ // unique tagId index. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js
956
+ // + ai/dualAgentAnnotation/tools/resolveInductiveBatch.js.
957
+ concurrency: 5,
947
958
  lockDuration: 3e5,
948
- // 5 minutes lock duration since annotation can be slow
949
- maxStalledCount: 3
959
+ // 5 min generous ceiling so heartbeat stutters don't trip stalled detection
960
+ // With attempts:1 a stalled job has no retry left anyway, but keeping
961
+ // stalled-count low ensures BullMQ doesn't mis-pickup a job whose
962
+ // worker is just CPU-busy.
963
+ maxStalledCount: 1
964
+ }
965
+ },
966
+ AI_AUTO_ANNOTATE_CHUNK_QUEUE: {
967
+ // CHILDREN queue in the per-doc Flow. One job per (doc, field, chunk).
968
+ // Each job calls okf-be /internal/getChunkSuggestions for its one chunk
969
+ // — a small fast call well under App Engine's 60s ceiling regardless
970
+ // of how large the source doc is. Failure of a single chunk does NOT
971
+ // kill the parent (children opt in via failParentOnFailure: false) —
972
+ // the parent's worker handles partial-success aggregation, mirroring
973
+ // the Promise.allSettled semantic at the BullMQ level.
974
+ //
975
+ // The progress tracker IGNORES this queue (the aggregator filters on
976
+ // AI_AUTO_ANNOTATE_QUEUE.id), so chunk granularity is available in
977
+ // job state for any future drill-in UI without disrupting today's
978
+ // doc-level progress UI.
979
+ id: "ai-auto-annotate-chunk-queue",
980
+ queueConfig: {
981
+ defaultJobOptions: {
982
+ // One try, no retries. A retry would re-fire the dual-agent LLM
983
+ // chain (annotator + moderator + attribute classifier) for the
984
+ // same chunk — expensive, and if the first try hit an OpenAI
985
+ // 429/timeout the retry will likely hit the same condition.
986
+ // Failed chunks surface to the parent via getFailedChildrenValues
987
+ // and become a partial-success on the field (the rest still apply).
988
+ attempts: 1,
989
+ backoff: {
990
+ type: "exponential",
991
+ delay: 5e3
992
+ },
993
+ removeOnComplete: 100,
994
+ // chunks fan out wider; keep a few more
995
+ removeOnFail: 300
996
+ },
997
+ streams: {
998
+ events: {
999
+ maxLen: 10
1000
+ }
1001
+ }
1002
+ },
1003
+ workerConfig: {
1004
+ // OpenAI gpt-4.1-mini TPM ceiling is 10M tokens/min. Each chunk
1005
+ // does ~4 LLM calls in series totalling ~22K tokens.
1006
+ // 5 chunks in flight × 4 calls/chunk × 60s / 15s-per-call
1007
+ // ≈ 80 calls/min × 6.5K tokens
1008
+ // ≈ 520K tokens/min sustained → ~5% of TPM ceiling.
1009
+ // Comfortable headroom for variance (long-tail chunks, bigger
1010
+ // taxonomies, mixed-tenant batches).
1011
+ concurrency: 5,
1012
+ lockDuration: 18e4,
1013
+ // 3 min — a single chunk's dual-agent run fits well under
1014
+ maxStalledCount: 1
950
1015
  }
951
1016
  },
952
1017
  ANNOS_ELASTIC_SYNC_QUEUE: {
@@ -2028,7 +2093,7 @@ var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks =
2028
2093
  filterType: "usersType",
2029
2094
  profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
2030
2095
  pinnedOptions: [
2031
- { display: "AI", value: null }
2096
+ { display: "AI", value: "-ai-as-author-" }
2032
2097
  ]
2033
2098
  },
2034
2099
  target: {