@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.
package/dist/node.d.mts CHANGED
@@ -604,7 +604,7 @@ declare namespace BASE_BULLMQ_CONFIG {
604
604
  }
605
605
  export { workerConfig_7 as workerConfig };
606
606
  }
607
- namespace ANNOS_ELASTIC_SYNC_QUEUE {
607
+ namespace AI_AUTO_ANNOTATE_CHUNK_QUEUE {
608
608
  let id_8: string;
609
609
  export { id_8 as id };
610
610
  export namespace queueConfig_8 {
@@ -644,7 +644,7 @@ declare namespace BASE_BULLMQ_CONFIG {
644
644
  }
645
645
  export { workerConfig_8 as workerConfig };
646
646
  }
647
- namespace CHUNKS_ELASTIC_SYNC_QUEUE {
647
+ namespace ANNOS_ELASTIC_SYNC_QUEUE {
648
648
  let id_9: string;
649
649
  export { id_9 as id };
650
650
  export namespace queueConfig_9 {
@@ -684,7 +684,7 @@ declare namespace BASE_BULLMQ_CONFIG {
684
684
  }
685
685
  export { workerConfig_9 as workerConfig };
686
686
  }
687
- namespace USERS_ELASTIC_SYNC_QUEUE {
687
+ namespace CHUNKS_ELASTIC_SYNC_QUEUE {
688
688
  let id_10: string;
689
689
  export { id_10 as id };
690
690
  export namespace queueConfig_10 {
@@ -724,7 +724,7 @@ declare namespace BASE_BULLMQ_CONFIG {
724
724
  }
725
725
  export { workerConfig_10 as workerConfig };
726
726
  }
727
- namespace CONTENT_ELASTIC_SYNC_QUEUE {
727
+ namespace USERS_ELASTIC_SYNC_QUEUE {
728
728
  let id_11: string;
729
729
  export { id_11 as id };
730
730
  export namespace queueConfig_11 {
@@ -764,7 +764,7 @@ declare namespace BASE_BULLMQ_CONFIG {
764
764
  }
765
765
  export { workerConfig_11 as workerConfig };
766
766
  }
767
- namespace SARVAM_TRANSCRIPTION_QUEUE {
767
+ namespace CONTENT_ELASTIC_SYNC_QUEUE {
768
768
  let id_12: string;
769
769
  export { id_12 as id };
770
770
  export namespace queueConfig_12 {
@@ -804,7 +804,7 @@ declare namespace BASE_BULLMQ_CONFIG {
804
804
  }
805
805
  export { workerConfig_12 as workerConfig };
806
806
  }
807
- namespace INTERCOM_CONVERSATIONS_QUEUE {
807
+ namespace SARVAM_TRANSCRIPTION_QUEUE {
808
808
  let id_13: string;
809
809
  export { id_13 as id };
810
810
  export namespace queueConfig_13 {
@@ -844,7 +844,7 @@ declare namespace BASE_BULLMQ_CONFIG {
844
844
  }
845
845
  export { workerConfig_13 as workerConfig };
846
846
  }
847
- namespace TAG_SYNC_PLAN_QUEUE {
847
+ namespace INTERCOM_CONVERSATIONS_QUEUE {
848
848
  let id_14: string;
849
849
  export { id_14 as id };
850
850
  export namespace queueConfig_14 {
@@ -884,7 +884,7 @@ declare namespace BASE_BULLMQ_CONFIG {
884
884
  }
885
885
  export { workerConfig_14 as workerConfig };
886
886
  }
887
- namespace TAG_SYNC_BATCH_QUEUE {
887
+ namespace TAG_SYNC_PLAN_QUEUE {
888
888
  let id_15: string;
889
889
  export { id_15 as id };
890
890
  export namespace queueConfig_15 {
@@ -924,11 +924,13 @@ declare namespace BASE_BULLMQ_CONFIG {
924
924
  }
925
925
  export { workerConfig_15 as workerConfig };
926
926
  }
927
- namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
927
+ namespace TAG_SYNC_BATCH_QUEUE {
928
928
  let id_16: string;
929
929
  export { id_16 as id };
930
930
  export namespace queueConfig_16 {
931
931
  export namespace defaultJobOptions_16 {
932
+ let attempts_16: number;
933
+ export { attempts_16 as attempts };
932
934
  export namespace backoff_16 {
933
935
  let type_16: string;
934
936
  export { type_16 as type };
@@ -936,8 +938,6 @@ declare namespace BASE_BULLMQ_CONFIG {
936
938
  export { delay_16 as delay };
937
939
  }
938
940
  export { backoff_16 as backoff };
939
- let attempts_16: number;
940
- export { attempts_16 as attempts };
941
941
  let removeOnComplete_16: number;
942
942
  export { removeOnComplete_16 as removeOnComplete };
943
943
  let removeOnFail_16: number;
@@ -964,13 +964,11 @@ declare namespace BASE_BULLMQ_CONFIG {
964
964
  }
965
965
  export { workerConfig_16 as workerConfig };
966
966
  }
967
- namespace REINDEX_QUEUE {
967
+ namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
968
968
  let id_17: string;
969
969
  export { id_17 as id };
970
970
  export namespace queueConfig_17 {
971
971
  export namespace defaultJobOptions_17 {
972
- let attempts_17: number;
973
- export { attempts_17 as attempts };
974
972
  export namespace backoff_17 {
975
973
  let type_17: string;
976
974
  export { type_17 as type };
@@ -978,8 +976,8 @@ declare namespace BASE_BULLMQ_CONFIG {
978
976
  export { delay_17 as delay };
979
977
  }
980
978
  export { backoff_17 as backoff };
981
- let delay_18: number;
982
- export { delay_18 as delay };
979
+ let attempts_17: number;
980
+ export { attempts_17 as attempts };
983
981
  let removeOnComplete_17: number;
984
982
  export { removeOnComplete_17 as removeOnComplete };
985
983
  let removeOnFail_17: number;
@@ -1006,6 +1004,48 @@ declare namespace BASE_BULLMQ_CONFIG {
1006
1004
  }
1007
1005
  export { workerConfig_17 as workerConfig };
1008
1006
  }
1007
+ namespace REINDEX_QUEUE {
1008
+ let id_18: string;
1009
+ export { id_18 as id };
1010
+ export namespace queueConfig_18 {
1011
+ export namespace defaultJobOptions_18 {
1012
+ let attempts_18: number;
1013
+ export { attempts_18 as attempts };
1014
+ export namespace backoff_18 {
1015
+ let type_18: string;
1016
+ export { type_18 as type };
1017
+ let delay_18: number;
1018
+ export { delay_18 as delay };
1019
+ }
1020
+ export { backoff_18 as backoff };
1021
+ let delay_19: number;
1022
+ export { delay_19 as delay };
1023
+ let removeOnComplete_18: number;
1024
+ export { removeOnComplete_18 as removeOnComplete };
1025
+ let removeOnFail_18: number;
1026
+ export { removeOnFail_18 as removeOnFail };
1027
+ }
1028
+ export { defaultJobOptions_18 as defaultJobOptions };
1029
+ export namespace streams_18 {
1030
+ export namespace events_18 {
1031
+ let maxLen_18: number;
1032
+ export { maxLen_18 as maxLen };
1033
+ }
1034
+ export { events_18 as events };
1035
+ }
1036
+ export { streams_18 as streams };
1037
+ }
1038
+ export { queueConfig_18 as queueConfig };
1039
+ export namespace workerConfig_18 {
1040
+ let concurrency_18: number;
1041
+ export { concurrency_18 as concurrency };
1042
+ let lockDuration_18: number;
1043
+ export { lockDuration_18 as lockDuration };
1044
+ let maxStalledCount_18: number;
1045
+ export { maxStalledCount_18 as maxStalledCount };
1046
+ }
1047
+ export { workerConfig_18 as workerConfig };
1048
+ }
1009
1049
  }
1010
1050
 
1011
1051
  interface PlatformContextContentItem {
@@ -1194,7 +1234,7 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1194
1234
  profileTypes: any[];
1195
1235
  pinnedOptions: {
1196
1236
  display: string;
1197
- value: null;
1237
+ value: string;
1198
1238
  }[];
1199
1239
  options?: undefined;
1200
1240
  };
@@ -1484,7 +1524,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1484
1524
  profileTypes: any[];
1485
1525
  pinnedOptions: {
1486
1526
  display: string;
1487
- value: null;
1527
+ value: string;
1488
1528
  }[];
1489
1529
  options?: undefined;
1490
1530
  };
package/dist/node.d.ts CHANGED
@@ -604,7 +604,7 @@ declare namespace BASE_BULLMQ_CONFIG {
604
604
  }
605
605
  export { workerConfig_7 as workerConfig };
606
606
  }
607
- namespace ANNOS_ELASTIC_SYNC_QUEUE {
607
+ namespace AI_AUTO_ANNOTATE_CHUNK_QUEUE {
608
608
  let id_8: string;
609
609
  export { id_8 as id };
610
610
  export namespace queueConfig_8 {
@@ -644,7 +644,7 @@ declare namespace BASE_BULLMQ_CONFIG {
644
644
  }
645
645
  export { workerConfig_8 as workerConfig };
646
646
  }
647
- namespace CHUNKS_ELASTIC_SYNC_QUEUE {
647
+ namespace ANNOS_ELASTIC_SYNC_QUEUE {
648
648
  let id_9: string;
649
649
  export { id_9 as id };
650
650
  export namespace queueConfig_9 {
@@ -684,7 +684,7 @@ declare namespace BASE_BULLMQ_CONFIG {
684
684
  }
685
685
  export { workerConfig_9 as workerConfig };
686
686
  }
687
- namespace USERS_ELASTIC_SYNC_QUEUE {
687
+ namespace CHUNKS_ELASTIC_SYNC_QUEUE {
688
688
  let id_10: string;
689
689
  export { id_10 as id };
690
690
  export namespace queueConfig_10 {
@@ -724,7 +724,7 @@ declare namespace BASE_BULLMQ_CONFIG {
724
724
  }
725
725
  export { workerConfig_10 as workerConfig };
726
726
  }
727
- namespace CONTENT_ELASTIC_SYNC_QUEUE {
727
+ namespace USERS_ELASTIC_SYNC_QUEUE {
728
728
  let id_11: string;
729
729
  export { id_11 as id };
730
730
  export namespace queueConfig_11 {
@@ -764,7 +764,7 @@ declare namespace BASE_BULLMQ_CONFIG {
764
764
  }
765
765
  export { workerConfig_11 as workerConfig };
766
766
  }
767
- namespace SARVAM_TRANSCRIPTION_QUEUE {
767
+ namespace CONTENT_ELASTIC_SYNC_QUEUE {
768
768
  let id_12: string;
769
769
  export { id_12 as id };
770
770
  export namespace queueConfig_12 {
@@ -804,7 +804,7 @@ declare namespace BASE_BULLMQ_CONFIG {
804
804
  }
805
805
  export { workerConfig_12 as workerConfig };
806
806
  }
807
- namespace INTERCOM_CONVERSATIONS_QUEUE {
807
+ namespace SARVAM_TRANSCRIPTION_QUEUE {
808
808
  let id_13: string;
809
809
  export { id_13 as id };
810
810
  export namespace queueConfig_13 {
@@ -844,7 +844,7 @@ declare namespace BASE_BULLMQ_CONFIG {
844
844
  }
845
845
  export { workerConfig_13 as workerConfig };
846
846
  }
847
- namespace TAG_SYNC_PLAN_QUEUE {
847
+ namespace INTERCOM_CONVERSATIONS_QUEUE {
848
848
  let id_14: string;
849
849
  export { id_14 as id };
850
850
  export namespace queueConfig_14 {
@@ -884,7 +884,7 @@ declare namespace BASE_BULLMQ_CONFIG {
884
884
  }
885
885
  export { workerConfig_14 as workerConfig };
886
886
  }
887
- namespace TAG_SYNC_BATCH_QUEUE {
887
+ namespace TAG_SYNC_PLAN_QUEUE {
888
888
  let id_15: string;
889
889
  export { id_15 as id };
890
890
  export namespace queueConfig_15 {
@@ -924,11 +924,13 @@ declare namespace BASE_BULLMQ_CONFIG {
924
924
  }
925
925
  export { workerConfig_15 as workerConfig };
926
926
  }
927
- namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
927
+ namespace TAG_SYNC_BATCH_QUEUE {
928
928
  let id_16: string;
929
929
  export { id_16 as id };
930
930
  export namespace queueConfig_16 {
931
931
  export namespace defaultJobOptions_16 {
932
+ let attempts_16: number;
933
+ export { attempts_16 as attempts };
932
934
  export namespace backoff_16 {
933
935
  let type_16: string;
934
936
  export { type_16 as type };
@@ -936,8 +938,6 @@ declare namespace BASE_BULLMQ_CONFIG {
936
938
  export { delay_16 as delay };
937
939
  }
938
940
  export { backoff_16 as backoff };
939
- let attempts_16: number;
940
- export { attempts_16 as attempts };
941
941
  let removeOnComplete_16: number;
942
942
  export { removeOnComplete_16 as removeOnComplete };
943
943
  let removeOnFail_16: number;
@@ -964,13 +964,11 @@ declare namespace BASE_BULLMQ_CONFIG {
964
964
  }
965
965
  export { workerConfig_16 as workerConfig };
966
966
  }
967
- namespace REINDEX_QUEUE {
967
+ namespace SCHEDULED_EXTERNAL_SYNC_QUEUE {
968
968
  let id_17: string;
969
969
  export { id_17 as id };
970
970
  export namespace queueConfig_17 {
971
971
  export namespace defaultJobOptions_17 {
972
- let attempts_17: number;
973
- export { attempts_17 as attempts };
974
972
  export namespace backoff_17 {
975
973
  let type_17: string;
976
974
  export { type_17 as type };
@@ -978,8 +976,8 @@ declare namespace BASE_BULLMQ_CONFIG {
978
976
  export { delay_17 as delay };
979
977
  }
980
978
  export { backoff_17 as backoff };
981
- let delay_18: number;
982
- export { delay_18 as delay };
979
+ let attempts_17: number;
980
+ export { attempts_17 as attempts };
983
981
  let removeOnComplete_17: number;
984
982
  export { removeOnComplete_17 as removeOnComplete };
985
983
  let removeOnFail_17: number;
@@ -1006,6 +1004,48 @@ declare namespace BASE_BULLMQ_CONFIG {
1006
1004
  }
1007
1005
  export { workerConfig_17 as workerConfig };
1008
1006
  }
1007
+ namespace REINDEX_QUEUE {
1008
+ let id_18: string;
1009
+ export { id_18 as id };
1010
+ export namespace queueConfig_18 {
1011
+ export namespace defaultJobOptions_18 {
1012
+ let attempts_18: number;
1013
+ export { attempts_18 as attempts };
1014
+ export namespace backoff_18 {
1015
+ let type_18: string;
1016
+ export { type_18 as type };
1017
+ let delay_18: number;
1018
+ export { delay_18 as delay };
1019
+ }
1020
+ export { backoff_18 as backoff };
1021
+ let delay_19: number;
1022
+ export { delay_19 as delay };
1023
+ let removeOnComplete_18: number;
1024
+ export { removeOnComplete_18 as removeOnComplete };
1025
+ let removeOnFail_18: number;
1026
+ export { removeOnFail_18 as removeOnFail };
1027
+ }
1028
+ export { defaultJobOptions_18 as defaultJobOptions };
1029
+ export namespace streams_18 {
1030
+ export namespace events_18 {
1031
+ let maxLen_18: number;
1032
+ export { maxLen_18 as maxLen };
1033
+ }
1034
+ export { events_18 as events };
1035
+ }
1036
+ export { streams_18 as streams };
1037
+ }
1038
+ export { queueConfig_18 as queueConfig };
1039
+ export namespace workerConfig_18 {
1040
+ let concurrency_18: number;
1041
+ export { concurrency_18 as concurrency };
1042
+ let lockDuration_18: number;
1043
+ export { lockDuration_18 as lockDuration };
1044
+ let maxStalledCount_18: number;
1045
+ export { maxStalledCount_18 as maxStalledCount };
1046
+ }
1047
+ export { workerConfig_18 as workerConfig };
1048
+ }
1009
1049
  }
1010
1050
 
1011
1051
  interface PlatformContextContentItem {
@@ -1194,7 +1234,7 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1194
1234
  profileTypes: any[];
1195
1235
  pinnedOptions: {
1196
1236
  display: string;
1197
- value: null;
1237
+ value: string;
1198
1238
  }[];
1199
1239
  options?: undefined;
1200
1240
  };
@@ -1484,7 +1524,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1484
1524
  profileTypes: any[];
1485
1525
  pinnedOptions: {
1486
1526
  display: string;
1487
- value: null;
1527
+ value: string;
1488
1528
  }[];
1489
1529
  options?: undefined;
1490
1530
  };
package/dist/node.js CHANGED
@@ -247,6 +247,15 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
247
247
  }
248
248
  },
249
249
  AI_AUTO_ANNOTATE_QUEUE: {
250
+ // PARENT queue in the per-doc Flow. One job per doc; child jobs (one
251
+ // per chunk) live on AI_AUTO_ANNOTATE_CHUNK_QUEUE. BullMQ Flow fires
252
+ // the parent only after all children settle. Parent job's worker
253
+ // collects children's suggestions, runs ONE doc-level inductive batch
254
+ // dedup, applies merged annotations to editor state, writes the doc.
255
+ //
256
+ // The progress tracker aggregator (calculateSegByAutoAnnotateIdJobs in
257
+ // okf-sub) filters by this queue's id, so parents = 1 job per doc
258
+ // matches the existing FE progress counting semantics 1:1.
250
259
  id: "ai-auto-annotate-queue",
251
260
  queueConfig: {
252
261
  defaultJobOptions: {
@@ -265,14 +274,70 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
265
274
  }
266
275
  },
267
276
  workerConfig: {
268
- // Parallel-safe: createTag/createSubTheme catch E11000 on the unique tagId
269
- // index and re-fetch the existing doc, so concurrent jobs proposing the
270
- // same tag converge to one. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js.
271
- // Starting at 10; real ceiling is the LLM provider's rate limit.
272
- concurrency: 15,
277
+ // Parallel-safe across docs: per-doc isolation on annotations.tags
278
+ // rollup (each parent processes a different doc); tenant-level Redis
279
+ // lock in resolveInductiveBatch serializes inductive dedup across
280
+ // concurrent parents; createTag/createSubTheme catch E11000 on the
281
+ // unique tagId index. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js
282
+ // + ai/dualAgentAnnotation/tools/resolveInductiveBatch.js.
283
+ concurrency: 5,
273
284
  lockDuration: 3e5,
274
- // 5 minutes lock duration since annotation can be slow
275
- maxStalledCount: 3
285
+ // 5 min generous ceiling so heartbeat stutters don't trip stalled detection
286
+ // With attempts:1 a stalled job has no retry left anyway, but keeping
287
+ // stalled-count low ensures BullMQ doesn't mis-pickup a job whose
288
+ // worker is just CPU-busy.
289
+ maxStalledCount: 1
290
+ }
291
+ },
292
+ AI_AUTO_ANNOTATE_CHUNK_QUEUE: {
293
+ // CHILDREN queue in the per-doc Flow. One job per (doc, field, chunk).
294
+ // Each job calls okf-be /internal/getChunkSuggestions for its one chunk
295
+ // — a small fast call well under App Engine's 60s ceiling regardless
296
+ // of how large the source doc is. Failure of a single chunk does NOT
297
+ // kill the parent (children opt in via failParentOnFailure: false) —
298
+ // the parent's worker handles partial-success aggregation, mirroring
299
+ // the Promise.allSettled semantic at the BullMQ level.
300
+ //
301
+ // The progress tracker IGNORES this queue (the aggregator filters on
302
+ // AI_AUTO_ANNOTATE_QUEUE.id), so chunk granularity is available in
303
+ // job state for any future drill-in UI without disrupting today's
304
+ // doc-level progress UI.
305
+ id: "ai-auto-annotate-chunk-queue",
306
+ queueConfig: {
307
+ defaultJobOptions: {
308
+ // One try, no retries. A retry would re-fire the dual-agent LLM
309
+ // chain (annotator + moderator + attribute classifier) for the
310
+ // same chunk — expensive, and if the first try hit an OpenAI
311
+ // 429/timeout the retry will likely hit the same condition.
312
+ // Failed chunks surface to the parent via getFailedChildrenValues
313
+ // and become a partial-success on the field (the rest still apply).
314
+ attempts: 1,
315
+ backoff: {
316
+ type: "exponential",
317
+ delay: 5e3
318
+ },
319
+ removeOnComplete: 100,
320
+ // chunks fan out wider; keep a few more
321
+ removeOnFail: 300
322
+ },
323
+ streams: {
324
+ events: {
325
+ maxLen: 10
326
+ }
327
+ }
328
+ },
329
+ workerConfig: {
330
+ // OpenAI gpt-4.1-mini TPM ceiling is 10M tokens/min. Each chunk
331
+ // does ~4 LLM calls in series totalling ~22K tokens.
332
+ // 5 chunks in flight × 4 calls/chunk × 60s / 15s-per-call
333
+ // ≈ 80 calls/min × 6.5K tokens
334
+ // ≈ 520K tokens/min sustained → ~5% of TPM ceiling.
335
+ // Comfortable headroom for variance (long-tail chunks, bigger
336
+ // taxonomies, mixed-tenant batches).
337
+ concurrency: 5,
338
+ lockDuration: 18e4,
339
+ // 3 min — a single chunk's dual-agent run fits well under
340
+ maxStalledCount: 1
276
341
  }
277
342
  },
278
343
  ANNOS_ELASTIC_SYNC_QUEUE: {
@@ -3703,7 +3768,7 @@ var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks =
3703
3768
  filterType: "usersType",
3704
3769
  profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
3705
3770
  pinnedOptions: [
3706
- { display: "AI", value: null }
3771
+ { display: "AI", value: "-ai-as-author-" }
3707
3772
  ]
3708
3773
  },
3709
3774
  target: {
package/dist/node.mjs CHANGED
@@ -252,6 +252,15 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
252
252
  }
253
253
  },
254
254
  AI_AUTO_ANNOTATE_QUEUE: {
255
+ // PARENT queue in the per-doc Flow. One job per doc; child jobs (one
256
+ // per chunk) live on AI_AUTO_ANNOTATE_CHUNK_QUEUE. BullMQ Flow fires
257
+ // the parent only after all children settle. Parent job's worker
258
+ // collects children's suggestions, runs ONE doc-level inductive batch
259
+ // dedup, applies merged annotations to editor state, writes the doc.
260
+ //
261
+ // The progress tracker aggregator (calculateSegByAutoAnnotateIdJobs in
262
+ // okf-sub) filters by this queue's id, so parents = 1 job per doc
263
+ // matches the existing FE progress counting semantics 1:1.
255
264
  id: "ai-auto-annotate-queue",
256
265
  queueConfig: {
257
266
  defaultJobOptions: {
@@ -270,14 +279,70 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
270
279
  }
271
280
  },
272
281
  workerConfig: {
273
- // Parallel-safe: createTag/createSubTheme catch E11000 on the unique tagId
274
- // index and re-fetch the existing doc, so concurrent jobs proposing the
275
- // same tag converge to one. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js.
276
- // Starting at 10; real ceiling is the LLM provider's rate limit.
277
- concurrency: 15,
282
+ // Parallel-safe across docs: per-doc isolation on annotations.tags
283
+ // rollup (each parent processes a different doc); tenant-level Redis
284
+ // lock in resolveInductiveBatch serializes inductive dedup across
285
+ // concurrent parents; createTag/createSubTheme catch E11000 on the
286
+ // unique tagId index. See ai/dualAgentAnnotation/tools/createTaxonomyItem.js
287
+ // + ai/dualAgentAnnotation/tools/resolveInductiveBatch.js.
288
+ concurrency: 5,
278
289
  lockDuration: 3e5,
279
- // 5 minutes lock duration since annotation can be slow
280
- maxStalledCount: 3
290
+ // 5 min generous ceiling so heartbeat stutters don't trip stalled detection
291
+ // With attempts:1 a stalled job has no retry left anyway, but keeping
292
+ // stalled-count low ensures BullMQ doesn't mis-pickup a job whose
293
+ // worker is just CPU-busy.
294
+ maxStalledCount: 1
295
+ }
296
+ },
297
+ AI_AUTO_ANNOTATE_CHUNK_QUEUE: {
298
+ // CHILDREN queue in the per-doc Flow. One job per (doc, field, chunk).
299
+ // Each job calls okf-be /internal/getChunkSuggestions for its one chunk
300
+ // — a small fast call well under App Engine's 60s ceiling regardless
301
+ // of how large the source doc is. Failure of a single chunk does NOT
302
+ // kill the parent (children opt in via failParentOnFailure: false) —
303
+ // the parent's worker handles partial-success aggregation, mirroring
304
+ // the Promise.allSettled semantic at the BullMQ level.
305
+ //
306
+ // The progress tracker IGNORES this queue (the aggregator filters on
307
+ // AI_AUTO_ANNOTATE_QUEUE.id), so chunk granularity is available in
308
+ // job state for any future drill-in UI without disrupting today's
309
+ // doc-level progress UI.
310
+ id: "ai-auto-annotate-chunk-queue",
311
+ queueConfig: {
312
+ defaultJobOptions: {
313
+ // One try, no retries. A retry would re-fire the dual-agent LLM
314
+ // chain (annotator + moderator + attribute classifier) for the
315
+ // same chunk — expensive, and if the first try hit an OpenAI
316
+ // 429/timeout the retry will likely hit the same condition.
317
+ // Failed chunks surface to the parent via getFailedChildrenValues
318
+ // and become a partial-success on the field (the rest still apply).
319
+ attempts: 1,
320
+ backoff: {
321
+ type: "exponential",
322
+ delay: 5e3
323
+ },
324
+ removeOnComplete: 100,
325
+ // chunks fan out wider; keep a few more
326
+ removeOnFail: 300
327
+ },
328
+ streams: {
329
+ events: {
330
+ maxLen: 10
331
+ }
332
+ }
333
+ },
334
+ workerConfig: {
335
+ // OpenAI gpt-4.1-mini TPM ceiling is 10M tokens/min. Each chunk
336
+ // does ~4 LLM calls in series totalling ~22K tokens.
337
+ // 5 chunks in flight × 4 calls/chunk × 60s / 15s-per-call
338
+ // ≈ 80 calls/min × 6.5K tokens
339
+ // ≈ 520K tokens/min sustained → ~5% of TPM ceiling.
340
+ // Comfortable headroom for variance (long-tail chunks, bigger
341
+ // taxonomies, mixed-tenant batches).
342
+ concurrency: 5,
343
+ lockDuration: 18e4,
344
+ // 3 min — a single chunk's dual-agent run fits well under
345
+ maxStalledCount: 1
281
346
  }
282
347
  },
283
348
  ANNOS_ELASTIC_SYNC_QUEUE: {
@@ -3633,7 +3698,7 @@ var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks =
3633
3698
  filterType: "usersType",
3634
3699
  profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
3635
3700
  pinnedOptions: [
3636
- { display: "AI", value: null }
3701
+ { display: "AI", value: "-ai-as-author-" }
3637
3702
  ]
3638
3703
  },
3639
3704
  target: {