@semiont/jobs 0.5.37 → 0.5.39

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JobId, UserId, UnitCursor, ResourceId, EntityType, JobReferenceAnnotationResult, GenerationJobParams, JobHighlightAnnotationResult, JobAssessmentAnnotationResult, JobCommentAnnotationResult, TagSchema, JobTagAnnotationResult, Logger, EventBus, components, Annotation, SupportedMediaType, GatheredContext } from '@semiont/core';
1
+ import { JobId, UserId, UnitCursor, ResourceId, EntityType, JobReferenceAnnotationResult, GenerationJobParams, JobHighlightAnnotationResult, JobAssessmentAnnotationResult, JobCommentAnnotationResult, TagSchema, JobTagAnnotationResult, Logger, EventBus, components, Annotation, SupportedMediaType, GatheredContext, EventMap } from '@semiont/core';
2
2
  import { SemiontState } from '@semiont/core/node';
3
3
  import { InferenceClient } from '@semiont/inference';
4
4
 
@@ -363,6 +363,15 @@ interface JobQueue {
363
363
  cancelled: number;
364
364
  }>;
365
365
  }
366
+ /**
367
+ * Every bus channel a queue DRIVER emits, maintained beside the interface
368
+ * both drivers implement and censused against their sources
369
+ * (queue-emits-census.test.ts). The gateway's signal bridge forwards these
370
+ * from its local bus onto the plane — a queue announcement that stays on
371
+ * the raw bus reaches no worker under a remote driver (the job:queued
372
+ * starvation, 2026-09-15).
373
+ */
374
+ declare const JOB_QUEUE_EMITS: readonly ["job:queued"];
366
375
 
367
376
  /**
368
377
  * Job Queue Manager
@@ -546,6 +555,14 @@ declare class FsJobQueue implements JobQueue {
546
555
  * handle escapes this file.
547
556
  */
548
557
 
558
+ /**
559
+ * The JOBS stream's capture filter — exported as the ONE home of the fact.
560
+ * A JetStream stream is a server-side subscription: anything published under
561
+ * these subjects is persisted regardless of which client API produced it.
562
+ * The signal plane's disjointness gate derives from this export instead of
563
+ * restating it (SIGNAL-PLANE D3 gate 3).
564
+ */
565
+ declare const JOBS_STREAM_SUBJECTS: readonly ["jobs.>"];
549
566
  interface JetStreamJobQueueOptions {
550
567
  /** NATS server address(es), e.g. "192.168.64.42:4222". */
551
568
  servers: string | string[];
@@ -1029,6 +1046,26 @@ declare function generateResourceFromTopic(topic: string, entityTypes: string[],
1029
1046
  * guarantee a blocked loop defeats is not one; the janitor is the guarantee.
1030
1047
  */
1031
1048
  declare const STALL_THRESHOLD_MS: number;
1049
+ /**
1050
+ * The broadcasts a worker CONSUMES — announcements nobody replies to, which
1051
+ * therefore derive from no operation.
1052
+ *
1053
+ * One home, because the alternative was proven: these lived as `addChannels`
1054
+ * calls beside their consumers, so the worker's complete set existed nowhere
1055
+ * and a widening could be deleted without any list getting shorter. That is
1056
+ * the 2026-09-16 outage — every worker idle on a `job:queued` its transport
1057
+ * would never carry, `lastQueuedEventAt: null`, nothing thrown and nothing
1058
+ * logged.
1059
+ *
1060
+ * An entry here must have a consumer and a consumer must have an entry; the
1061
+ * census beside this file asserts both directions.
1062
+ */
1063
+ declare const WORKER_CONSUMED_BROADCASTS: readonly ["job:queued", "job:cancel-requested"];
1064
+ /**
1065
+ * The global SSE channel set for a worker's transport: the whole manifest,
1066
+ * stated once and passed at construction. Nothing widens it afterwards.
1067
+ */
1068
+ declare const WORKER_CHANNELS: readonly (keyof EventMap)[];
1032
1069
 
1033
- export { AnnotationDetection, FsJobQueue, JetStreamJobQueue, STALL_THRESHOLD_MS, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob, processAssessmentJob, processCommentJob, processGenerationJob, processHighlightJob, processReferenceJob, processTagJob };
1070
+ export { AnnotationDetection, FsJobQueue, JOBS_STREAM_SUBJECTS, JOB_QUEUE_EMITS, JetStreamJobQueue, STALL_THRESHOLD_MS, WORKER_CHANNELS, WORKER_CONSUMED_BROADCASTS, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob, processAssessmentJob, processCommentJob, processGenerationJob, processHighlightJob, processReferenceJob, processTagJob };
1034
1071
  export type { AnyJob, AssessmentDetectionJob, AssessmentDetectionParams, AssessmentDetectionProgress, CancelledJob, CommentDetectionJob, CommentDetectionParams, CommentDetectionProgress, CompleteJob, DetectionJob, DetectionParams, DetectionProgress, FailedJob, GenerationJob, GenerationResult, HighlightDetectionJob, HighlightDetectionParams, HighlightDetectionProgress, JetStreamJobQueueOptions, JobMetadata, JobQueryFilters, JobQueue, JobStatus, JobType, OnProgress, PendingJob, ProcessorResult, RunningJob, TagDetectionJob, TagDetectionParams, TagDetectionProgress, YieldProgress };
package/dist/index.js CHANGED
@@ -12,7 +12,8 @@ import '@semiont/event-sourcing';
12
12
  import '@semiont/sdk';
13
13
  import '@semiont/http-transport';
14
14
 
15
- // src/fs-job-queue.ts
15
+ // src/job-queue-interface.ts
16
+ var JOB_QUEUE_EMITS = ["job:queued"];
16
17
 
17
18
  // src/will-retry.ts
18
19
  function willRetryAfter(metadata, failureClass) {
@@ -110,7 +111,7 @@ var FsJobQueue = class {
110
111
  */
111
112
  announce(job) {
112
113
  if (this.eventBus && "params" in job && "resourceId" in job.params) {
113
- this.eventBus.get("job:queued").next({
114
+ this.eventBus.emit("job:queued", {
114
115
  jobId: job.metadata.id,
115
116
  jobType: job.metadata.type,
116
117
  resourceId: job.params.resourceId,
@@ -517,6 +518,7 @@ var PROGRESS_WRITE_MIN_INTERVAL_MS2 = 5e3;
517
518
  var MAX_CAS_ATTEMPTS = 20;
518
519
  var enc = new TextEncoder();
519
520
  var dec = new TextDecoder();
521
+ var JOBS_STREAM_SUBJECTS = ["jobs.>"];
520
522
  function categoryOf(type) {
521
523
  return type === "generation" ? "generation" : "annotation";
522
524
  }
@@ -565,7 +567,7 @@ var JetStreamJobQueue = class {
565
567
  } catch {
566
568
  await this.jsm.streams.add({
567
569
  name: STREAM,
568
- subjects: ["jobs.>"],
570
+ subjects: [...JOBS_STREAM_SUBJECTS],
569
571
  retention: RetentionPolicy.Workqueue
570
572
  });
571
573
  }
@@ -671,7 +673,7 @@ var JetStreamJobQueue = class {
671
673
  /** Same wire shape as the fs driver: only jobs with a resourceId announce. */
672
674
  announce(job) {
673
675
  if (this.eventBus && "params" in job && "resourceId" in job.params) {
674
- this.eventBus.get("job:queued").next({
676
+ this.eventBus.emit("job:queued", {
675
677
  jobId: job.metadata.id,
676
678
  jobType: job.metadata.type,
677
679
  resourceId: job.params.resourceId,
@@ -2933,8 +2935,17 @@ var WORKER_AWAITED_OPERATIONS = [
2933
2935
  // rare error path is no reason to let it back in.
2934
2936
  "browse:annotation-requested"
2935
2937
  ];
2936
- replyChannelsFor(WORKER_AWAITED_OPERATIONS);
2938
+ var WORKER_CONSUMED_BROADCASTS = [
2939
+ // The queue announcement the claim adapter races for.
2940
+ "job:queued",
2941
+ // Cooperative cancellation of the ACTIVE job (JOB-RESTART-SAFETY P4).
2942
+ "job:cancel-requested"
2943
+ ];
2944
+ var WORKER_CHANNELS = [
2945
+ ...replyChannelsFor(WORKER_AWAITED_OPERATIONS),
2946
+ ...WORKER_CONSUMED_BROADCASTS
2947
+ ];
2937
2948
 
2938
- export { AnnotationDetection, FsJobQueue, JetStreamJobQueue, STALL_THRESHOLD_MS, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob, processAssessmentJob, processCommentJob, processGenerationJob, processHighlightJob, processReferenceJob, processTagJob };
2949
+ export { AnnotationDetection, FsJobQueue, JOBS_STREAM_SUBJECTS, JOB_QUEUE_EMITS, JetStreamJobQueue, STALL_THRESHOLD_MS, WORKER_CHANNELS, WORKER_CONSUMED_BROADCASTS, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob, processAssessmentJob, processCommentJob, processGenerationJob, processHighlightJob, processReferenceJob, processTagJob };
2939
2950
  //# sourceMappingURL=index.js.map
2940
2951
  //# sourceMappingURL=index.js.map