@growth-labs/cms 0.8.26 → 0.8.28

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.
Files changed (61) hide show
  1. package/README.md +23 -0
  2. package/dist/engine/published-content.d.ts +4 -0
  3. package/dist/engine/published-content.d.ts.map +1 -1
  4. package/dist/engine/published-content.js +52 -16
  5. package/dist/engine/published-content.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/integration/options.d.ts +226 -13
  11. package/dist/integration/options.d.ts.map +1 -1
  12. package/dist/integration/options.js +17 -2
  13. package/dist/integration/options.js.map +1 -1
  14. package/dist/providers/types.d.ts +10 -0
  15. package/dist/providers/types.d.ts.map +1 -1
  16. package/dist/providers/types.js.map +1 -1
  17. package/dist/routes/content-insights.d.ts +4 -0
  18. package/dist/routes/content-insights.d.ts.map +1 -1
  19. package/dist/routes/content-insights.js +104 -0
  20. package/dist/routes/content-insights.js.map +1 -1
  21. package/dist/routes/surveys.d.ts.map +1 -1
  22. package/dist/routes/surveys.js +80 -4
  23. package/dist/routes/surveys.js.map +1 -1
  24. package/dist/schema/insights-ingest.d.ts +64 -64
  25. package/dist/surveys/auto-label.d.ts +31 -4
  26. package/dist/surveys/auto-label.d.ts.map +1 -1
  27. package/dist/surveys/auto-label.js +160 -29
  28. package/dist/surveys/auto-label.js.map +1 -1
  29. package/dist/surveys/schema.d.ts +155 -0
  30. package/dist/surveys/schema.d.ts.map +1 -1
  31. package/dist/surveys/schema.js +49 -0
  32. package/dist/surveys/schema.js.map +1 -1
  33. package/dist/ui/api/content/insights-inputs.d.ts.map +1 -1
  34. package/dist/ui/api/content/insights-inputs.js +11 -1
  35. package/dist/ui/api/content/insights-inputs.js.map +1 -1
  36. package/dist/ui/client/mount.d.ts.map +1 -1
  37. package/dist/ui/client/mount.js +1 -0
  38. package/dist/ui/client/mount.js.map +1 -1
  39. package/dist/ui/screens/SurveyResponsesScreen.d.ts +18 -3
  40. package/dist/ui/screens/SurveyResponsesScreen.d.ts.map +1 -1
  41. package/dist/ui/screens/SurveyResponsesScreen.js +75 -18
  42. package/dist/ui/screens/SurveyResponsesScreen.js.map +1 -1
  43. package/dist/ui/screens/registry.d.ts +3 -1
  44. package/dist/ui/screens/registry.d.ts.map +1 -1
  45. package/dist/ui/screens/registry.js +4 -2
  46. package/dist/ui/screens/registry.js.map +1 -1
  47. package/dist/ui/styles/broadsheet.css +1 -0
  48. package/package.json +1 -1
  49. package/src/engine/published-content.ts +75 -16
  50. package/src/index.ts +1 -0
  51. package/src/integration/options.ts +21 -1
  52. package/src/providers/types.ts +9 -0
  53. package/src/routes/content-insights.ts +104 -0
  54. package/src/routes/surveys.ts +106 -4
  55. package/src/surveys/auto-label.ts +204 -33
  56. package/src/surveys/schema.ts +58 -0
  57. package/src/ui/api/content/insights-inputs.ts +8 -1
  58. package/src/ui/client/mount.tsx +1 -0
  59. package/src/ui/screens/SurveyResponsesScreen.tsx +198 -18
  60. package/src/ui/screens/registry.tsx +6 -2
  61. package/src/ui/styles/broadsheet.css +1 -0
@@ -1631,14 +1631,6 @@ export declare const InsightSuggestionRowSchema: z.ZodObject<{
1631
1631
  beat: z.ZodNullable<z.ZodEnum<["defense", "intelligence", "diplomacy", "analysis"]>>;
1632
1632
  }, "strip", z.ZodTypeAny, {
1633
1633
  desk: string;
1634
- site_id: string;
1635
- run_date: string;
1636
- suggestion_type: "cluster" | "tracker";
1637
- signal_type: "demand" | "opportunity";
1638
- is_best_bet: 0 | 1;
1639
- best_bet_rank: number | null;
1640
- desk_rank: number;
1641
- headline: string;
1642
1634
  evidence: {
1643
1635
  position: number;
1644
1636
  query: string;
@@ -1720,6 +1712,14 @@ export declare const InsightSuggestionRowSchema: z.ZodObject<{
1720
1712
  } | undefined;
1721
1713
  } | undefined;
1722
1714
  };
1715
+ site_id: string;
1716
+ run_date: string;
1717
+ suggestion_type: "cluster" | "tracker";
1718
+ signal_type: "demand" | "opportunity";
1719
+ is_best_bet: 0 | 1;
1720
+ best_bet_rank: number | null;
1721
+ desk_rank: number;
1722
+ headline: string;
1723
1723
  brief: {
1724
1724
  cluster: {
1725
1725
  canonical: string;
@@ -1754,14 +1754,6 @@ export declare const InsightSuggestionRowSchema: z.ZodObject<{
1754
1754
  beat: "defense" | "intelligence" | "diplomacy" | "analysis" | null;
1755
1755
  }, {
1756
1756
  desk: string;
1757
- site_id: string;
1758
- run_date: string;
1759
- suggestion_type: "cluster" | "tracker";
1760
- signal_type: "demand" | "opportunity";
1761
- is_best_bet: 0 | 1;
1762
- best_bet_rank: number | null;
1763
- desk_rank: number;
1764
- headline: string;
1765
1757
  evidence: {
1766
1758
  position: number;
1767
1759
  query: string;
@@ -1843,6 +1835,14 @@ export declare const InsightSuggestionRowSchema: z.ZodObject<{
1843
1835
  } | undefined;
1844
1836
  } | undefined;
1845
1837
  };
1838
+ site_id: string;
1839
+ run_date: string;
1840
+ suggestion_type: "cluster" | "tracker";
1841
+ signal_type: "demand" | "opportunity";
1842
+ is_best_bet: 0 | 1;
1843
+ best_bet_rank: number | null;
1844
+ desk_rank: number;
1845
+ headline: string;
1846
1846
  brief: {
1847
1847
  cluster: {
1848
1848
  canonical: string;
@@ -2528,14 +2528,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2528
2528
  beat: z.ZodNullable<z.ZodEnum<["defense", "intelligence", "diplomacy", "analysis"]>>;
2529
2529
  }, "strip", z.ZodTypeAny, {
2530
2530
  desk: string;
2531
- site_id: string;
2532
- run_date: string;
2533
- suggestion_type: "cluster" | "tracker";
2534
- signal_type: "demand" | "opportunity";
2535
- is_best_bet: 0 | 1;
2536
- best_bet_rank: number | null;
2537
- desk_rank: number;
2538
- headline: string;
2539
2531
  evidence: {
2540
2532
  position: number;
2541
2533
  query: string;
@@ -2617,6 +2609,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2617
2609
  } | undefined;
2618
2610
  } | undefined;
2619
2611
  };
2612
+ site_id: string;
2613
+ run_date: string;
2614
+ suggestion_type: "cluster" | "tracker";
2615
+ signal_type: "demand" | "opportunity";
2616
+ is_best_bet: 0 | 1;
2617
+ best_bet_rank: number | null;
2618
+ desk_rank: number;
2619
+ headline: string;
2620
2620
  brief: {
2621
2621
  cluster: {
2622
2622
  canonical: string;
@@ -2651,14 +2651,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2651
2651
  beat: "defense" | "intelligence" | "diplomacy" | "analysis" | null;
2652
2652
  }, {
2653
2653
  desk: string;
2654
- site_id: string;
2655
- run_date: string;
2656
- suggestion_type: "cluster" | "tracker";
2657
- signal_type: "demand" | "opportunity";
2658
- is_best_bet: 0 | 1;
2659
- best_bet_rank: number | null;
2660
- desk_rank: number;
2661
- headline: string;
2662
2654
  evidence: {
2663
2655
  position: number;
2664
2656
  query: string;
@@ -2740,6 +2732,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2740
2732
  } | undefined;
2741
2733
  } | undefined;
2742
2734
  };
2735
+ site_id: string;
2736
+ run_date: string;
2737
+ suggestion_type: "cluster" | "tracker";
2738
+ signal_type: "demand" | "opportunity";
2739
+ is_best_bet: 0 | 1;
2740
+ best_bet_rank: number | null;
2741
+ desk_rank: number;
2742
+ headline: string;
2743
2743
  brief: {
2744
2744
  cluster: {
2745
2745
  canonical: string;
@@ -2776,14 +2776,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2776
2776
  }, "strip", z.ZodTypeAny, {
2777
2777
  rows: {
2778
2778
  desk: string;
2779
- site_id: string;
2780
- run_date: string;
2781
- suggestion_type: "cluster" | "tracker";
2782
- signal_type: "demand" | "opportunity";
2783
- is_best_bet: 0 | 1;
2784
- best_bet_rank: number | null;
2785
- desk_rank: number;
2786
- headline: string;
2787
2779
  evidence: {
2788
2780
  position: number;
2789
2781
  query: string;
@@ -2865,6 +2857,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2865
2857
  } | undefined;
2866
2858
  } | undefined;
2867
2859
  };
2860
+ site_id: string;
2861
+ run_date: string;
2862
+ suggestion_type: "cluster" | "tracker";
2863
+ signal_type: "demand" | "opportunity";
2864
+ is_best_bet: 0 | 1;
2865
+ best_bet_rank: number | null;
2866
+ desk_rank: number;
2867
+ headline: string;
2868
2868
  brief: {
2869
2869
  cluster: {
2870
2870
  canonical: string;
@@ -2916,14 +2916,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
2916
2916
  }, {
2917
2917
  rows: {
2918
2918
  desk: string;
2919
- site_id: string;
2920
- run_date: string;
2921
- suggestion_type: "cluster" | "tracker";
2922
- signal_type: "demand" | "opportunity";
2923
- is_best_bet: 0 | 1;
2924
- best_bet_rank: number | null;
2925
- desk_rank: number;
2926
- headline: string;
2927
2919
  evidence: {
2928
2920
  position: number;
2929
2921
  query: string;
@@ -3005,6 +2997,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
3005
2997
  } | undefined;
3006
2998
  } | undefined;
3007
2999
  };
3000
+ site_id: string;
3001
+ run_date: string;
3002
+ suggestion_type: "cluster" | "tracker";
3003
+ signal_type: "demand" | "opportunity";
3004
+ is_best_bet: 0 | 1;
3005
+ best_bet_rank: number | null;
3006
+ desk_rank: number;
3007
+ headline: string;
3008
3008
  brief: {
3009
3009
  cluster: {
3010
3010
  canonical: string;
@@ -3056,14 +3056,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
3056
3056
  }>, {
3057
3057
  rows: {
3058
3058
  desk: string;
3059
- site_id: string;
3060
- run_date: string;
3061
- suggestion_type: "cluster" | "tracker";
3062
- signal_type: "demand" | "opportunity";
3063
- is_best_bet: 0 | 1;
3064
- best_bet_rank: number | null;
3065
- desk_rank: number;
3066
- headline: string;
3067
3059
  evidence: {
3068
3060
  position: number;
3069
3061
  query: string;
@@ -3145,6 +3137,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
3145
3137
  } | undefined;
3146
3138
  } | undefined;
3147
3139
  };
3140
+ site_id: string;
3141
+ run_date: string;
3142
+ suggestion_type: "cluster" | "tracker";
3143
+ signal_type: "demand" | "opportunity";
3144
+ is_best_bet: 0 | 1;
3145
+ best_bet_rank: number | null;
3146
+ desk_rank: number;
3147
+ headline: string;
3148
3148
  brief: {
3149
3149
  cluster: {
3150
3150
  canonical: string;
@@ -3196,14 +3196,6 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
3196
3196
  }, {
3197
3197
  rows: {
3198
3198
  desk: string;
3199
- site_id: string;
3200
- run_date: string;
3201
- suggestion_type: "cluster" | "tracker";
3202
- signal_type: "demand" | "opportunity";
3203
- is_best_bet: 0 | 1;
3204
- best_bet_rank: number | null;
3205
- desk_rank: number;
3206
- headline: string;
3207
3199
  evidence: {
3208
3200
  position: number;
3209
3201
  query: string;
@@ -3285,6 +3277,14 @@ export declare const InsightsIngestPayloadSchema: z.ZodEffects<z.ZodObject<{
3285
3277
  } | undefined;
3286
3278
  } | undefined;
3287
3279
  };
3280
+ site_id: string;
3281
+ run_date: string;
3282
+ suggestion_type: "cluster" | "tracker";
3283
+ signal_type: "demand" | "opportunity";
3284
+ is_best_bet: 0 | 1;
3285
+ best_bet_rank: number | null;
3286
+ desk_rank: number;
3287
+ headline: string;
3288
3288
  brief: {
3289
3289
  cluster: {
3290
3290
  canonical: string;
@@ -1,6 +1,7 @@
1
+ import { z } from 'zod';
1
2
  import type { D1Database } from '../engine/d1.js';
2
3
  import type { LlmDispatch } from '../providers/types.js';
3
- import type { SurveyAnswerLabel } from './schema.js';
4
+ import { type SurveyAnswerLabel } from './schema.js';
4
5
  /** The masthead-ai-assist task for survey classification. Foundry does not
5
6
  * validate `task` (articlechain/mastheadaiassist.go: "a sixth Masthead action
6
7
  * added later on the cms/Fronts side needs no Go change"), so this needs no
@@ -60,6 +61,9 @@ export interface SurveyAutoLabelAttemptRecord {
60
61
  nextAt: number;
61
62
  /** Epoch ms until another request's dispatch claims this answer. */
62
63
  inflightUntil: number;
64
+ /** Opaque Go correlation, never reader text or identity. */
65
+ taskId?: string;
66
+ reason?: 'callback_expired' | 'dispatch_failed' | 'llm_failed' | 'unparseable';
63
67
  }
64
68
  /** Narrow persistence the batch runner needs; the KV adapter below satisfies
65
69
  * it, and tests supply an in-memory double. */
@@ -67,6 +71,8 @@ export interface SurveyAutoLabelAttemptStore {
67
71
  get(key: string): Promise<SurveyAutoLabelAttemptRecord | null>;
68
72
  put(key: string, record: SurveyAutoLabelAttemptRecord, ttlSeconds: number): Promise<void>;
69
73
  delete(key: string): Promise<void>;
74
+ putTask?(taskId: string, record: SurveyAutoLabelTaskRecord): Promise<void>;
75
+ getTask?(taskId: string): Promise<SurveyAutoLabelTaskRecord | null>;
70
76
  }
71
77
  export declare function surveyAutoLabelAttemptKey(surveyId: string, responseId: string, questionId: string): string;
72
78
  /** Minimal KV shape — structurally compatible with Workers KVNamespace, so
@@ -78,10 +84,31 @@ interface KvLike {
78
84
  }): Promise<unknown>;
79
85
  delete(key: string): Promise<unknown>;
80
86
  }
81
- /** Attempt records in a Workers KV namespace (`survey-autolabel:` prefix).
82
- * The same namespace the host's LlmDispatch result slots live in is fine:
83
- * the key prefixes never collide (`masthead:llm:result:` vs ours). */
87
+ declare const TaskRecordSchema: z.ZodObject<{
88
+ surveyId: z.ZodString;
89
+ responseId: z.ZodString;
90
+ questionId: z.ZodString;
91
+ attempts: z.ZodNumber;
92
+ }, "strict", z.ZodTypeAny, {
93
+ questionId: string;
94
+ responseId: string;
95
+ surveyId: string;
96
+ attempts: number;
97
+ }, {
98
+ questionId: string;
99
+ responseId: string;
100
+ surveyId: string;
101
+ attempts: number;
102
+ }>;
103
+ export type SurveyAutoLabelTaskRecord = z.infer<typeof TaskRecordSchema>;
104
+ export declare const SURVEY_AUTO_LABEL_TASK_PREFIX = "survey-autolabel-task:";
84
105
  export declare function kvSurveyAutoLabelAttemptStore(kv: KvLike): SurveyAutoLabelAttemptStore;
106
+ /** Finalize through the existing signed callback, independently of waitUntil.
107
+ * Missing correlation/persistence throws so Go retries rather than acknowledging lost work. */
108
+ export declare function finalizeSurveyAutoLabel(db: D1Database, store: SurveyAutoLabelAttemptStore, taskId: string, result: {
109
+ terminalState: 'completed' | 'failed';
110
+ result?: string;
111
+ }, now?: number): Promise<void>;
85
112
  export interface SurveyAutoLabelOptions {
86
113
  surveyId: string;
87
114
  db: D1Database;
@@ -1 +1 @@
1
- {"version":3,"file":"auto-label.d.ts","sourceRoot":"","sources":["../../src/surveys/auto-label.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD;;;uBAGuB;AACvB,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AAExD,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,sDAAsD;AACtD,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAE9C,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,QAAiB,CAAA;AAE3D,4EAA4E;AAC5E,eAAO,MAAM,8BAA8B,IAAI,CAAA;AAE/C,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,UAIxC,CAAA;AAED;;8CAE8C;AAC9C,eAAO,MAAM,qCAAqC,QAAmB,CAAA;AAErE;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CA2BzF;AAQD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAK7E;AAiB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AAM,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,sBAAsB,EAC/B,KAAK,EAAE,wBAAwB,EAAE,GAC/B,IAAI,CAGN"}
@@ -10,6 +10,8 @@
10
10
  // already in flight or has failed too often (B1), and a deterministic PII
11
11
  // pre-filter plus <answer> delimiting so personal details never reach the
12
12
  // model and reader text is framed as data, not instructions (B2).
13
+ import { z } from 'zod';
14
+ import { BoundedRecordIdSchema, SurveyIdSchema, SurveyQuestionIdSchema, } from './schema.js';
13
15
  /** The masthead-ai-assist task for survey classification. Foundry does not
14
16
  * validate `task` (articlechain/mastheadaiassist.go: "a sixth Masthead action
15
17
  * added later on the cms/Fronts side needs no Go change"), so this needs no
@@ -118,32 +120,93 @@ export function surveyAutoLabelAttemptKey(surveyId, responseId, questionId) {
118
120
  /** Attempt records in a Workers KV namespace (`survey-autolabel:` prefix).
119
121
  * The same namespace the host's LlmDispatch result slots live in is fine:
120
122
  * the key prefixes never collide (`masthead:llm:result:` vs ours). */
123
+ const AttemptRecordSchema = z
124
+ .object({
125
+ attempts: z.number().int().nonnegative(),
126
+ nextAt: z.number().nonnegative(),
127
+ inflightUntil: z.number().nonnegative(),
128
+ taskId: z.string().min(1).max(256).optional(),
129
+ reason: z.enum(['callback_expired', 'dispatch_failed', 'llm_failed', 'unparseable']).optional(),
130
+ })
131
+ .strict();
132
+ const TaskRecordSchema = z
133
+ .object({
134
+ surveyId: SurveyIdSchema,
135
+ responseId: BoundedRecordIdSchema,
136
+ questionId: SurveyQuestionIdSchema,
137
+ attempts: z.number().int().nonnegative(),
138
+ })
139
+ .strict();
140
+ export const SURVEY_AUTO_LABEL_TASK_PREFIX = 'survey-autolabel-task:';
121
141
  export function kvSurveyAutoLabelAttemptStore(kv) {
122
142
  return {
123
143
  async get(key) {
124
144
  const raw = await kv.get(key);
125
- if (raw === null)
126
- return null;
127
- try {
128
- const value = JSON.parse(raw);
129
- return {
130
- attempts: typeof value.attempts === 'number' ? value.attempts : 0,
131
- nextAt: typeof value.nextAt === 'number' ? value.nextAt : 0,
132
- inflightUntil: typeof value.inflightUntil === 'number' ? value.inflightUntil : 0,
133
- };
134
- }
135
- catch {
136
- return null;
137
- }
145
+ return raw === null ? null : AttemptRecordSchema.parse(JSON.parse(raw));
138
146
  },
139
147
  async put(key, record, ttlSeconds) {
140
- await kv.put(key, JSON.stringify(record), { expirationTtl: ttlSeconds });
148
+ await kv.put(key, JSON.stringify(AttemptRecordSchema.parse(record)), {
149
+ expirationTtl: ttlSeconds,
150
+ });
141
151
  },
142
152
  async delete(key) {
143
153
  await kv.delete(key);
144
154
  },
155
+ async putTask(taskId, record) {
156
+ await kv.put(`${SURVEY_AUTO_LABEL_TASK_PREFIX}${taskId}`, JSON.stringify(TaskRecordSchema.parse(record)), { expirationTtl: SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS });
157
+ },
158
+ async getTask(taskId) {
159
+ const raw = await kv.get(`${SURVEY_AUTO_LABEL_TASK_PREFIX}${taskId}`);
160
+ return raw === null ? null : TaskRecordSchema.parse(JSON.parse(raw));
161
+ },
145
162
  };
146
163
  }
164
+ /** Finalize through the existing signed callback, independently of waitUntil.
165
+ * Missing correlation/persistence throws so Go retries rather than acknowledging lost work. */
166
+ export async function finalizeSurveyAutoLabel(db, store, taskId, result, now = Date.now()) {
167
+ const target = await store.getTask?.(taskId);
168
+ if (!target)
169
+ throw new Error('survey correlation unavailable');
170
+ const key = surveyAutoLabelAttemptKey(target.surveyId, target.responseId, target.questionId);
171
+ const label = result.terminalState === 'completed' ? parseSurveyLabelReply(result.result ?? '') : null;
172
+ if (label) {
173
+ await db
174
+ .prepare(`INSERT INTO survey_answer_labels
175
+ (survey_id, response_id, question_id, label, source, labeled_by, labeled_at)
176
+ VALUES (?, ?, ?, ?, 'auto', NULL, ?)
177
+ ON CONFLICT(survey_id, response_id, question_id) DO NOTHING`)
178
+ .bind(target.surveyId, target.responseId, target.questionId, label, now)
179
+ .run();
180
+ const current = await store.get(key);
181
+ if (current?.taskId === taskId)
182
+ await store.delete(key);
183
+ return;
184
+ }
185
+ const existing = await db
186
+ .prepare('SELECT label FROM survey_answer_labels WHERE survey_id = ? AND response_id = ? AND question_id = ? LIMIT 1')
187
+ .bind(target.surveyId, target.responseId, target.questionId)
188
+ .first();
189
+ if (existing)
190
+ return;
191
+ const current = await store.get(key);
192
+ if (!current)
193
+ throw new Error('survey attempt unavailable');
194
+ if (current.taskId === taskId &&
195
+ current.inflightUntil === 0 &&
196
+ current.attempts > target.attempts)
197
+ return;
198
+ // A delayed failed callback must not reset a newer retry or a completed label.
199
+ if (current?.taskId !== taskId)
200
+ return;
201
+ const attempts = target.attempts + 1;
202
+ await store.put(key, {
203
+ attempts,
204
+ nextAt: now + SURVEY_AUTO_LABEL_BACKOFF_MS[Math.min(attempts, 3) - 1],
205
+ inflightUntil: 0,
206
+ taskId,
207
+ reason: result.terminalState === 'failed' ? 'llm_failed' : 'unparseable',
208
+ }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS);
209
+ }
147
210
  /**
148
211
  * In-isolate in-flight gate. KV has no compare-and-swap, so a dedupe window
149
212
  * this small is enforced synchronously in module scope (all concurrent
@@ -182,19 +245,36 @@ export function scheduleSurveyAutoLabel(options, batch) {
182
245
  */
183
246
  async function runSurveyAutoLabelBatch(options, batch) {
184
247
  let cursor = 0;
248
+ let admitted = 0;
249
+ const reserveAdmission = () => {
250
+ if (admitted >= SURVEY_AUTO_LABEL_BATCH_LIMIT)
251
+ return false;
252
+ admitted += 1;
253
+ return true;
254
+ };
185
255
  let stored = 0;
256
+ let processed = 0;
186
257
  let deferred = 0;
187
258
  let halted = null;
259
+ const admissionDeadline = (options.now ?? Date.now)() + 20_000;
188
260
  const skipReasons = new Set();
189
261
  const worker = async () => {
190
262
  for (;;) {
191
- if (halted !== null)
263
+ if (halted !== null || admitted >= SURVEY_AUTO_LABEL_BATCH_LIMIT)
264
+ return;
265
+ if ((options.now ?? Date.now)() >= admissionDeadline) {
266
+ halted = 'admission_window_ended';
192
267
  return;
268
+ }
193
269
  const next = cursor;
194
270
  cursor += 1;
195
271
  if (next >= batch.length)
196
272
  return;
197
- const outcome = await classifyAndStore(options, batch[next]);
273
+ const outcome = await classifyAndStore(options, batch[next], reserveAdmission).catch(() => ({
274
+ kind: 'unavailable',
275
+ reason: 'attempt_write_failed',
276
+ }));
277
+ processed += 1;
198
278
  if (outcome.kind === 'stored') {
199
279
  stored += 1;
200
280
  continue;
@@ -218,7 +298,7 @@ async function runSurveyAutoLabelBatch(options, batch) {
218
298
  await Promise.all(Array.from({ length: Math.min(SURVEY_AUTO_LABEL_CONCURRENCY, batch.length) }, () => worker()));
219
299
  // Failure-class skips only: a wholly deferred batch (all in flight or
220
300
  // backing off) is the steady state of the dedupe, not a failure to report.
221
- const skipped = batch.length - stored - deferred;
301
+ const skipped = (halted === null ? processed : batch.length) - stored - deferred;
222
302
  if (skipped === 0)
223
303
  return;
224
304
  const reasons = new Set(skipReasons);
@@ -230,7 +310,9 @@ async function runSurveyAutoLabelBatch(options, batch) {
230
310
  reason: reasons.size === 1 ? [...reasons][0] : 'mixed',
231
311
  });
232
312
  }
233
- async function classifyAndStore(options, candidate) {
313
+ async function classifyAndStore(options, candidate, reserveAdmission) {
314
+ if (candidate.answerText.trim().length === 0)
315
+ return { kind: 'deferred', reason: 'empty' };
234
316
  // B2 first, before any store or dispatch work: personal details never
235
317
  // leave the Worker, and the skip consumes no attempt.
236
318
  if (containsPersonalDetails(candidate.answerText))
@@ -242,13 +324,22 @@ async function classifyAndStore(options, candidate) {
242
324
  record = await options.attempts.get(key);
243
325
  }
244
326
  catch {
245
- // The attempt store is dedupe hygiene, not label correctness: an
246
- // unreadable record proceeds as if absent (worst case: one duplicate
247
- // dispatch, still bounded by the in-isolate gate).
327
+ return { kind: 'unavailable', reason: 'attempt_read_failed' };
248
328
  }
249
329
  if (record) {
250
330
  if (record.inflightUntil > now)
251
331
  return { kind: 'deferred', reason: 'in_flight' };
332
+ if (record.inflightUntil > 0) {
333
+ const attempts = record.attempts + 1;
334
+ await options.attempts.put(key, {
335
+ attempts,
336
+ nextAt: now + SURVEY_AUTO_LABEL_BACKOFF_MS[Math.min(attempts, 3) - 1],
337
+ inflightUntil: 0,
338
+ ...(record.taskId ? { taskId: record.taskId } : {}),
339
+ reason: 'callback_expired',
340
+ }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS);
341
+ return { kind: 'deferred', reason: 'backoff' };
342
+ }
252
343
  if (record.attempts >= SURVEY_AUTO_LABEL_MAX_ATTEMPTS) {
253
344
  return { kind: 'deferred', reason: 'gave_up' };
254
345
  }
@@ -258,6 +349,8 @@ async function classifyAndStore(options, candidate) {
258
349
  if (!reserveInFlight(key, now))
259
350
  return { kind: 'deferred', reason: 'in_flight' };
260
351
  try {
352
+ if (!reserveAdmission())
353
+ return { kind: 'deferred', reason: 'batch_limit' };
261
354
  // Claimed. Record the failure (or the backoff it earns) at each exit;
262
355
  // the KV marker goes out BEFORE the dispatch so a concurrent request
263
356
  // in another isolate defers instead of duplicating the work.
@@ -265,17 +358,55 @@ async function classifyAndStore(options, candidate) {
265
358
  const attempts = (record?.attempts ?? 0) + 1;
266
359
  const backoff = SURVEY_AUTO_LABEL_BACKOFF_MS[Math.min(attempts, SURVEY_AUTO_LABEL_BACKOFF_MS.length) - 1];
267
360
  await options.attempts
268
- .put(key, { attempts, nextAt: now + backoff, inflightUntil: 0 }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS)
361
+ .put(key, {
362
+ attempts,
363
+ nextAt: now + backoff,
364
+ inflightUntil: 0,
365
+ reason: outcome.reason === 'unparseable' ? 'unparseable' : 'dispatch_failed',
366
+ }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS)
269
367
  .catch(() => { });
270
368
  return outcome;
271
369
  };
272
- await options.attempts
273
- .put(key, {
274
- attempts: record?.attempts ?? 0,
275
- nextAt: record?.nextAt ?? 0,
276
- inflightUntil: now + SURVEY_AUTO_LABEL_INFLIGHT_MS,
277
- }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS)
278
- .catch(() => { });
370
+ if (!options.llm.submit)
371
+ await options.attempts
372
+ .put(key, {
373
+ attempts: record?.attempts ?? 0,
374
+ nextAt: record?.nextAt ?? 0,
375
+ inflightUntil: now + SURVEY_AUTO_LABEL_INFLIGHT_MS,
376
+ }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS)
377
+ .catch(() => {
378
+ throw new Error('attempt_write_failed');
379
+ });
380
+ if (options.llm.submit) {
381
+ if (!options.attempts.putTask)
382
+ return await failure({ kind: 'unavailable', reason: 'no_correlation_store' });
383
+ let admission;
384
+ try {
385
+ admission = await options.llm.submit({
386
+ task: SURVEY_AUTO_LABEL_TASK,
387
+ prompt: buildSurveyLabelPrompt(candidate.questionPrompt, candidate.answerText),
388
+ }, async (taskId) => {
389
+ await options.attempts.putTask(taskId, {
390
+ surveyId: options.surveyId,
391
+ responseId: candidate.responseId,
392
+ questionId: candidate.questionId,
393
+ attempts: record?.attempts ?? 0,
394
+ });
395
+ await options.attempts.put(key, {
396
+ attempts: record?.attempts ?? 0,
397
+ nextAt: 0,
398
+ inflightUntil: now + SURVEY_AUTO_LABEL_INFLIGHT_MS,
399
+ taskId,
400
+ }, SURVEY_AUTO_LABEL_ATTEMPT_TTL_SECONDS);
401
+ });
402
+ }
403
+ catch {
404
+ return await failure({ kind: 'unavailable', reason: 'dispatch_threw' });
405
+ }
406
+ if (admission.status === 'unavailable')
407
+ return await failure({ kind: 'unavailable', reason: admission.reason });
408
+ return { kind: 'deferred', reason: 'in_flight' };
409
+ }
279
410
  let result;
280
411
  try {
281
412
  result = await options.llm.dispatch({
@@ -1 +1 @@
1
- {"version":3,"file":"auto-label.js","sourceRoot":"","sources":["../../src/surveys/auto-label.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,4EAA4E;AAC5E,4EAA4E;AAC5E,uEAAuE;AACvE,4EAA4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