@hogsend/core 0.1.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogsend/core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "drizzle-orm": "^0.45.2",
32
32
  "iana-db-timezones": "^0.3.0",
33
33
  "zod": "^4.4.3",
34
- "@hogsend/db": "^0.1.0"
34
+ "@hogsend/db": "^0.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "latest",
@@ -0,0 +1,163 @@
1
+ import type { DurationObject } from "../duration.js";
2
+ import type {
3
+ CompositeCondition,
4
+ ConditionEval,
5
+ EventCondition,
6
+ PropertyCondition,
7
+ } from "../types/conditions.js";
8
+
9
+ type CountOperator = NonNullable<EventCondition["operator"]>;
10
+
11
+ /** Fluent property predicate. Each terminal returns a plain PropertyCondition. */
12
+ export interface PropertyMatcher {
13
+ eq(value: string | number | boolean): PropertyCondition;
14
+ neq(value: string | number | boolean): PropertyCondition;
15
+ gt(value: number): PropertyCondition;
16
+ gte(value: number): PropertyCondition;
17
+ lt(value: number): PropertyCondition;
18
+ lte(value: number): PropertyCondition;
19
+ contains(value: string | number | boolean): PropertyCondition;
20
+ exists(): PropertyCondition;
21
+ notExists(): PropertyCondition;
22
+ }
23
+
24
+ /**
25
+ * Fluent event predicate. The optional `.within(window)` precedes the terminal
26
+ * (`b.event("x").within(days(7)).notExists()`) so every terminal still returns a
27
+ * clean EventCondition POJO — no wrapper objects to unwrap.
28
+ */
29
+ export interface EventMatcher {
30
+ /** Constrain to a rolling window — this is what makes a bucket time-based. */
31
+ within(window: DurationObject): EventMatcher;
32
+ exists(): EventCondition;
33
+ notExists(): EventCondition;
34
+ count(operator: CountOperator, value: number): EventCondition;
35
+ atLeast(value: number): EventCondition;
36
+ moreThan(value: number): EventCondition;
37
+ atMost(value: number): EventCondition;
38
+ lessThan(value: number): EventCondition;
39
+ exactly(value: number): EventCondition;
40
+ }
41
+
42
+ /**
43
+ * The fluent builder passed to a `defineBucket` criteria function. Every terminal
44
+ * returns a plain `ConditionEval` POJO — byte-identical to the declarative form —
45
+ * so the registry indexes, schema validation, reconcile cron, and Studio all keep
46
+ * working unchanged. The function runs ONCE, at bucket-definition time; it never
47
+ * executes per-user, so criteria stays introspectable data.
48
+ */
49
+ export interface CriteriaBuilder {
50
+ prop(property: string): PropertyMatcher;
51
+ event(eventName: string): EventMatcher;
52
+ /** Composite AND over the given conditions. */
53
+ all(...conditions: ConditionEval[]): CompositeCondition;
54
+ /** Composite OR over the given conditions. */
55
+ any(...conditions: ConditionEval[]): CompositeCondition;
56
+ }
57
+
58
+ class PropertyMatcherImpl implements PropertyMatcher {
59
+ private readonly property: string;
60
+ constructor(property: string) {
61
+ this.property = property;
62
+ }
63
+ private make(
64
+ operator: PropertyCondition["operator"],
65
+ value?: string | number | boolean,
66
+ ): PropertyCondition {
67
+ return {
68
+ type: "property",
69
+ property: this.property,
70
+ operator,
71
+ ...(value !== undefined ? { value } : {}),
72
+ };
73
+ }
74
+ eq(value: string | number | boolean): PropertyCondition {
75
+ return this.make("eq", value);
76
+ }
77
+ neq(value: string | number | boolean): PropertyCondition {
78
+ return this.make("neq", value);
79
+ }
80
+ gt(value: number): PropertyCondition {
81
+ return this.make("gt", value);
82
+ }
83
+ gte(value: number): PropertyCondition {
84
+ return this.make("gte", value);
85
+ }
86
+ lt(value: number): PropertyCondition {
87
+ return this.make("lt", value);
88
+ }
89
+ lte(value: number): PropertyCondition {
90
+ return this.make("lte", value);
91
+ }
92
+ contains(value: string | number | boolean): PropertyCondition {
93
+ return this.make("contains", value);
94
+ }
95
+ exists(): PropertyCondition {
96
+ return this.make("exists");
97
+ }
98
+ notExists(): PropertyCondition {
99
+ return this.make("not_exists");
100
+ }
101
+ }
102
+
103
+ class EventMatcherImpl implements EventMatcher {
104
+ private readonly eventName: string;
105
+ private readonly window?: DurationObject;
106
+ constructor(eventName: string, window?: DurationObject) {
107
+ this.eventName = eventName;
108
+ this.window = window;
109
+ }
110
+ within(window: DurationObject): EventMatcher {
111
+ return new EventMatcherImpl(this.eventName, window);
112
+ }
113
+ private make(
114
+ check: EventCondition["check"],
115
+ operator?: CountOperator,
116
+ value?: number,
117
+ ): EventCondition {
118
+ return {
119
+ type: "event",
120
+ eventName: this.eventName,
121
+ check,
122
+ ...(operator !== undefined ? { operator } : {}),
123
+ ...(value !== undefined ? { value } : {}),
124
+ ...(this.window !== undefined ? { within: this.window } : {}),
125
+ };
126
+ }
127
+ exists(): EventCondition {
128
+ return this.make("exists");
129
+ }
130
+ notExists(): EventCondition {
131
+ return this.make("not_exists");
132
+ }
133
+ count(operator: CountOperator, value: number): EventCondition {
134
+ return this.make("count", operator, value);
135
+ }
136
+ atLeast(value: number): EventCondition {
137
+ return this.make("count", "gte", value);
138
+ }
139
+ moreThan(value: number): EventCondition {
140
+ return this.make("count", "gt", value);
141
+ }
142
+ atMost(value: number): EventCondition {
143
+ return this.make("count", "lte", value);
144
+ }
145
+ lessThan(value: number): EventCondition {
146
+ return this.make("count", "lt", value);
147
+ }
148
+ exactly(value: number): EventCondition {
149
+ return this.make("count", "eq", value);
150
+ }
151
+ }
152
+
153
+ /**
154
+ * The default {@link CriteriaBuilder} instance. `defineBucket` passes this to a
155
+ * criteria function and stores the returned `ConditionEval`. Exported so it can
156
+ * also be used standalone (e.g. composing reusable criteria fragments in tests).
157
+ */
158
+ export const criteriaBuilder: CriteriaBuilder = {
159
+ prop: (property) => new PropertyMatcherImpl(property),
160
+ event: (eventName) => new EventMatcherImpl(eventName),
161
+ all: (...conditions) => ({ type: "composite", operator: "and", conditions }),
162
+ any: (...conditions) => ({ type: "composite", operator: "or", conditions }),
163
+ };
@@ -1,3 +1,9 @@
1
+ export {
2
+ type CriteriaBuilder,
3
+ criteriaBuilder,
4
+ type EventMatcher,
5
+ type PropertyMatcher,
6
+ } from "./builder.js";
1
7
  export { type ConditionContext, evaluateCondition } from "./evaluate.js";
2
8
  export { evaluateEventCondition } from "./event.js";
3
9
  export { evaluatePropertyConditions } from "./property.js";
package/src/index.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  export {
2
2
  type ConditionContext,
3
+ type CriteriaBuilder,
4
+ criteriaBuilder,
5
+ type EventMatcher,
3
6
  evaluateCondition,
4
7
  evaluateEventCondition,
5
8
  evaluatePropertyConditions,
9
+ type PropertyMatcher,
6
10
  } from "./conditions/index.js";
7
11
  export {
8
12
  type DurationObject,
@@ -11,7 +15,12 @@ export {
11
15
  hours,
12
16
  minutes,
13
17
  } from "./duration.js";
14
- export { JourneyRegistry } from "./registry/index.js";
18
+ export {
19
+ BucketRegistry,
20
+ collectEventNames,
21
+ collectPropertyNames,
22
+ JourneyRegistry,
23
+ } from "./registry/index.js";
15
24
  export * from "./schedule/index.js";
16
- export { journeyMetaSchema } from "./schemas/index.js";
25
+ export { bucketMetaSchema, journeyMetaSchema } from "./schemas/index.js";
17
26
  export * from "./types/index.js";
@@ -0,0 +1,119 @@
1
+ import { bucketMetaSchema } from "../schemas/index.js";
2
+ import type { BucketMeta, ConditionEval } from "../types/index.js";
3
+
4
+ /**
5
+ * Walk a ConditionEval tree, collecting every EventCondition.eventName. Pure
6
+ * tree walk over the discriminated union, mirroring core/conditions/event.ts.
7
+ */
8
+ export function collectEventNames(criteria: ConditionEval): string[] {
9
+ const names: string[] = [];
10
+ const visit = (condition: ConditionEval): void => {
11
+ switch (condition.type) {
12
+ case "event":
13
+ names.push(condition.eventName);
14
+ break;
15
+ case "composite":
16
+ for (const child of condition.conditions) {
17
+ visit(child);
18
+ }
19
+ break;
20
+ default:
21
+ break;
22
+ }
23
+ };
24
+ visit(criteria);
25
+ return names;
26
+ }
27
+
28
+ /**
29
+ * Walk a ConditionEval tree, collecting every PropertyCondition.property. Pure
30
+ * tree walk over the discriminated union.
31
+ */
32
+ export function collectPropertyNames(criteria: ConditionEval): string[] {
33
+ const names: string[] = [];
34
+ const visit = (condition: ConditionEval): void => {
35
+ switch (condition.type) {
36
+ case "property":
37
+ names.push(condition.property);
38
+ break;
39
+ case "composite":
40
+ for (const child of condition.conditions) {
41
+ visit(child);
42
+ }
43
+ break;
44
+ default:
45
+ break;
46
+ }
47
+ };
48
+ visit(criteria);
49
+ return names;
50
+ }
51
+
52
+ export class BucketRegistry {
53
+ private buckets: Map<string, BucketMeta> = new Map();
54
+ private eventIndex: Map<string, BucketMeta[]> = new Map();
55
+ private propertyIndex: Map<string, BucketMeta[]> = new Map();
56
+ // degenerate: criteria reference neither a concrete event nor any property
57
+ private wildcard: BucketMeta[] = [];
58
+
59
+ register(bucket: BucketMeta): void {
60
+ const parsed = bucketMetaSchema.parse(bucket);
61
+ const validated = parsed as unknown as BucketMeta;
62
+
63
+ this.buckets.set(validated.id, validated);
64
+
65
+ // manual buckets are not criteria-driven → not indexed for real-time eval
66
+ if (validated.kind === "manual" || !validated.criteria) {
67
+ return;
68
+ }
69
+
70
+ const events = collectEventNames(validated.criteria);
71
+ const props = collectPropertyNames(validated.criteria);
72
+
73
+ for (const eventName of events) {
74
+ const existing = this.eventIndex.get(eventName) ?? [];
75
+ existing.push(validated);
76
+ this.eventIndex.set(eventName, existing);
77
+ }
78
+
79
+ for (const propName of props) {
80
+ const existing = this.propertyIndex.get(propName) ?? [];
81
+ existing.push(validated);
82
+ this.propertyIndex.set(propName, existing);
83
+ }
84
+
85
+ // "*" ONLY for criteria referencing neither a concrete event nor a property
86
+ // (degenerate; rare under the at-least-one-positive rule).
87
+ if (events.length === 0 && props.length === 0) {
88
+ this.wildcard.push(validated);
89
+ }
90
+ }
91
+
92
+ get(id: string): BucketMeta | undefined {
93
+ return this.buckets.get(id);
94
+ }
95
+
96
+ getByReferencedEvent(eventName: string): BucketMeta[] {
97
+ return [...(this.eventIndex.get(eventName) ?? []), ...this.wildcard];
98
+ }
99
+
100
+ getByReferencedProperty(propName: string): BucketMeta[] {
101
+ return this.propertyIndex.get(propName) ?? [];
102
+ }
103
+
104
+ getAll(): BucketMeta[] {
105
+ return Array.from(this.buckets.values());
106
+ }
107
+
108
+ getEnabled(): BucketMeta[] {
109
+ return this.getAll().filter((b) => b.enabled);
110
+ }
111
+
112
+ has(id: string): boolean {
113
+ return this.buckets.has(id);
114
+ }
115
+
116
+ count(): number {
117
+ return this.buckets.size;
118
+ }
119
+ }
@@ -1,6 +1,12 @@
1
1
  import { journeyMetaSchema } from "../schemas/index.js";
2
2
  import type { JourneyMeta } from "../types/index.js";
3
3
 
4
+ export {
5
+ BucketRegistry,
6
+ collectEventNames,
7
+ collectPropertyNames,
8
+ } from "./bucket.js";
9
+
4
10
  export class JourneyRegistry {
5
11
  private journeys: Map<string, JourneyMeta> = new Map();
6
12
  private triggerIndex: Map<string, JourneyMeta[]> = new Map();
@@ -0,0 +1,172 @@
1
+ import { z } from "zod";
2
+ import { durationToMs } from "../duration.js";
3
+ import type {
4
+ CompositeCondition,
5
+ ConditionEval,
6
+ EmailEngagementCondition,
7
+ EventCondition,
8
+ PropertyCondition,
9
+ } from "../types/conditions.js";
10
+ import { conditionEvalSchema } from "./journey.schema.js";
11
+
12
+ const durationObjectSchema = z.object({
13
+ hours: z.number().optional(),
14
+ minutes: z.number().optional(),
15
+ seconds: z.number().optional(),
16
+ });
17
+
18
+ /**
19
+ * Walk a ConditionEval tree, yielding every leaf node (property / event /
20
+ * email_engagement). Composites recurse into their `conditions` array. Mirrors
21
+ * the pure discriminated-union walks in core/conditions.
22
+ */
23
+ function* walkConditions(
24
+ condition: ConditionEval,
25
+ ): Generator<PropertyCondition | EventCondition | EmailEngagementCondition> {
26
+ if (condition.type === "composite") {
27
+ for (const child of (condition as CompositeCondition).conditions) {
28
+ yield* walkConditions(child);
29
+ }
30
+ return;
31
+ }
32
+ yield condition;
33
+ }
34
+
35
+ /**
36
+ * A leaf condition is "negative" when satisfying the bucket means the absence /
37
+ * inequality of data. A dynamic bucket whose every leaf is negative is
38
+ * degenerate/unbounded (the Customer.io rule), so at least one positive leaf is
39
+ * required.
40
+ *
41
+ * Exception: a TIME-BOUNDED behavioral absence — `event` `not_exists` with a
42
+ * `within` window ("did NOT do X in the last N") — is the canonical
43
+ * dormancy/churn predicate (e.g. the `went-dormant` bucket and the whole
44
+ * cron-reconcile leave path exist for it). It is bounded by its window, so it
45
+ * is NOT degenerate and counts as a legitimate anchor. Only an UNBOUNDED
46
+ * absence (`not_exists` with no `within`) matches nearly everyone and is
47
+ * treated as a pure-negation leaf.
48
+ */
49
+ function isNegativeLeaf(
50
+ leaf: PropertyCondition | EventCondition | EmailEngagementCondition,
51
+ ): boolean {
52
+ switch (leaf.type) {
53
+ case "property":
54
+ return leaf.operator === "neq" || leaf.operator === "not_exists";
55
+ case "event":
56
+ return leaf.check === "not_exists" && leaf.within === undefined;
57
+ case "email_engagement":
58
+ return leaf.check === "not_opened" || leaf.check === "not_clicked";
59
+ default:
60
+ return false;
61
+ }
62
+ }
63
+
64
+ export const bucketMetaSchema = z
65
+ .object({
66
+ id: z.string().min(1),
67
+ name: z.string().min(1),
68
+ description: z.string().optional(),
69
+ enabled: z.boolean(),
70
+
71
+ kind: z.enum(["dynamic", "manual"]).optional(),
72
+
73
+ criteria: conditionEvalSchema.optional(),
74
+
75
+ entryLimit: z.enum(["once", "once_per_period", "unlimited"]).optional(),
76
+ entryPeriod: durationObjectSchema.optional(),
77
+
78
+ minDwell: durationObjectSchema.optional(),
79
+ maxDwell: durationObjectSchema.optional(),
80
+
81
+ timeBased: z.boolean().optional(),
82
+ reconcileEvery: durationObjectSchema.optional(),
83
+ reconcileJoins: z.boolean().optional(),
84
+ fastExpiry: z.boolean().optional(),
85
+
86
+ syncToPostHog: z.boolean().optional(),
87
+ postHogPropertyKey: z.string().optional(),
88
+ })
89
+ .superRefine((meta, ctx) => {
90
+ const kind = meta.kind ?? "dynamic";
91
+ const criteria = meta.criteria as ConditionEval | undefined;
92
+
93
+ // minDwell is a floor, maxDwell an unconditional ceiling. A ceiling below the
94
+ // floor is contradictory — the TTL leave would be permanently blocked by the
95
+ // minDwell guard. Applies regardless of kind.
96
+ if (
97
+ meta.minDwell &&
98
+ meta.maxDwell &&
99
+ durationToMs(meta.maxDwell) < durationToMs(meta.minDwell)
100
+ ) {
101
+ ctx.addIssue({
102
+ code: "custom",
103
+ path: ["maxDwell"],
104
+ message: "maxDwell must be greater than or equal to minDwell.",
105
+ });
106
+ }
107
+
108
+ // Rule 4: kind/criteria coherence. `kind:"manual"` is declared on the
109
+ // discriminator for forward-compat (Phase 4) but is NOT implemented in v1 —
110
+ // it would register as a silent no-op (never populated by the real-time path
111
+ // or the reconcile cron). Reject it LOUDLY at registration time
112
+ // (bucketMetaSchema.parse) rather than accepting a bucket that can never
113
+ // gain members. This is a runtime-validation tightening, not a type break:
114
+ // the `kind` enum still allows declaring "manual".
115
+ if (kind === "manual") {
116
+ ctx.addIssue({
117
+ code: "custom",
118
+ path: ["kind"],
119
+ message:
120
+ 'kind:"manual" buckets are not implemented in v1; use a dynamic ' +
121
+ 'bucket (kind:"dynamic" with `criteria`) instead.',
122
+ });
123
+ return;
124
+ }
125
+
126
+ // kind:"dynamic" (or omitted) REQUIRES a non-empty criteria.
127
+ if (criteria === undefined) {
128
+ ctx.addIssue({
129
+ code: "custom",
130
+ path: ["criteria"],
131
+ message: 'kind:"dynamic" buckets require a non-empty `criteria`.',
132
+ });
133
+ return;
134
+ }
135
+
136
+ const leaves = Array.from(walkConditions(criteria));
137
+
138
+ // Rule 1: at-least-one-positive-condition (dynamic buckets only).
139
+ if (leaves.length > 0 && leaves.every(isNegativeLeaf)) {
140
+ ctx.addIssue({
141
+ code: "custom",
142
+ path: ["criteria"],
143
+ message:
144
+ "Dynamic buckets must contain at least one positive condition; " +
145
+ "pure-negation criteria are degenerate/unbounded.",
146
+ });
147
+ }
148
+
149
+ for (const leaf of leaves) {
150
+ // Rule 2: reserved-prefix rejection on EventCondition.eventName.
151
+ if (leaf.type === "event" && leaf.eventName.startsWith("bucket:")) {
152
+ ctx.addIssue({
153
+ code: "custom",
154
+ path: ["criteria"],
155
+ message:
156
+ "criteria must not reference a reserved `bucket:*` event name " +
157
+ `(found "${leaf.eventName}").`,
158
+ });
159
+ }
160
+
161
+ // Rule 3: email_engagement forbidden anywhere in v1.
162
+ if (leaf.type === "email_engagement") {
163
+ ctx.addIssue({
164
+ code: "custom",
165
+ path: ["criteria"],
166
+ message:
167
+ "email_engagement conditions are not allowed in bucket criteria " +
168
+ "in v1.",
169
+ });
170
+ }
171
+ }
172
+ });
@@ -1 +1,2 @@
1
+ export { bucketMetaSchema } from "./bucket.schema.js";
1
2
  export { journeyMetaSchema } from "./journey.schema.js";
@@ -0,0 +1,102 @@
1
+ import type { DurationObject } from "../duration.js";
2
+ import type { ConditionEval } from "./conditions.js";
3
+
4
+ export interface BucketMeta {
5
+ id: string;
6
+ name: string;
7
+ description?: string;
8
+ /** Static load-time flag (guard #1), mirrors JourneyMeta.enabled. */
9
+ enabled: boolean;
10
+
11
+ /**
12
+ * Discriminator, declared NOW for forward-compat even though "manual" ships in
13
+ * Phase 4. "dynamic" (default) = membership auto-recomputed from `criteria`;
14
+ * "manual" = membership mutated only by explicit API/import, NO criteria,
15
+ * skipped by checkBucketMembership and the reconcile cron (early-continue, the
16
+ * Laudspeaker pattern). Declaring it up front keeps Phase 4 genuinely additive
17
+ * — no breaking change to BucketMeta later. Default "dynamic".
18
+ *
19
+ * v1: kind:"manual" is REJECTED at registration time (bucketMetaSchema parse)
20
+ * because nothing populates a manual bucket yet — it would be a silent no-op.
21
+ * The value stays on the enum for forward-compat; use kind:"dynamic" with
22
+ * `criteria` until full manual membership ships.
23
+ */
24
+ kind?: "dynamic" | "manual";
25
+
26
+ /**
27
+ * Membership predicate — the existing 4-type condition engine
28
+ * (packages/core/src/conditions/evaluate.ts). Inclusion AND exclusion come
29
+ * for free via neq / not_exists / not_opened and event check:"not_exists".
30
+ * REQUIRED for kind:"dynamic" (omit/empty for kind:"manual"). Dynamic buckets
31
+ * MUST contain at least one positive condition (validated; pure-negation
32
+ * buckets are degenerate/unbounded — the Customer.io rule). The
33
+ * at-least-one-positive refine applies to dynamic buckets only.
34
+ * NOTE: criteria MUST NOT reference a reserved `bucket:*` event name in any
35
+ * EventCondition.eventName (rejected at registration — see 4.2), so transition
36
+ * rows can never satisfy a bucket predicate.
37
+ */
38
+ criteria?: ConditionEval;
39
+
40
+ /**
41
+ * Re-entry policy for EMITTED join events (maps onto checkEntryLimit
42
+ * semantics). "once" = emit bucket:entered once ever; "once_per_period" =
43
+ * re-emit only after a prior leave + period elapses; "unlimited" = always.
44
+ * Default "unlimited".
45
+ */
46
+ entryLimit?: "once" | "once_per_period" | "unlimited";
47
+ entryPeriod?: DurationObject;
48
+
49
+ /**
50
+ * Anti-flap: suppress bucket:left until membership has existed at least this
51
+ * long (debounce). Guards journeys from re-enroll spam on oscillation.
52
+ */
53
+ minDwell?: DurationObject;
54
+
55
+ /**
56
+ * Maximum dwell — an UNCONDITIONAL membership TTL. `maxDwell` after the user
57
+ * joined, the reconcile cron force-leaves them REGARDLESS of whether the
58
+ * criteria still match (contrast `within`, which is criteria-driven, and
59
+ * `minDwell`, which is a floor). Use it for time-boxed membership: "in this
60
+ * bucket for exactly N days, then out".
61
+ *
62
+ * Re-entry after a maxDwell exit is governed by `entryLimit` (per-bucket): pair
63
+ * with `entryLimit:"once"` / `"once_per_period"` for a HARD time-box (they stay
64
+ * out / cool off), or leave the default `"unlimited"` for a PERIODIC FLUSH
65
+ * (they re-join on their next qualifying event). Independent of `within` and
66
+ * `fastExpiry`; if `minDwell` is also set it must be <= `maxDwell` (validated).
67
+ * Enforced by the reconcile cron, so the exit lands within the reconcile
68
+ * cadence (default 5m), not to-the-second.
69
+ */
70
+ maxDwell?: DurationObject;
71
+
72
+ /**
73
+ * Reconciliation knobs.
74
+ * timeBased: criteria contain an event `within` window a clock can expire —
75
+ * the ONLY kind the cron sweep touches (candidate narrowing). Inferred from
76
+ * a criteria walk if omitted; an explicit value overrides.
77
+ * reconcileEvery: advisory cadence surfaced in Studio (the single engine-wide
78
+ * cron sweeps all time-based buckets; per-bucket cadence is informational).
79
+ * reconcileJoins: also re-evaluate JOINS in the sweep. Tri-state:
80
+ * `false` = hard OFF (cost-bounding override, even for absence buckets);
81
+ * `true` = explicit ON; `undefined` = INFERRED — ON only for absence-shaped
82
+ * criteria (a windowed `not_exists` leg, the sole shape a clock can JOIN, so
83
+ * went-dormant works with no extra config), OFF otherwise (the real-time
84
+ * path already catches positive joins on event arrival; keep the sweep
85
+ * O(active members)).
86
+ * fastExpiry: opt-in per-user durable timer for sub-second absence-leave on
87
+ * latency-critical buckets (Approach A graft). The cron remains the
88
+ * authoritative backstop. Default false.
89
+ */
90
+ timeBased?: boolean;
91
+ reconcileEvery?: DurationObject;
92
+ reconcileJoins?: boolean;
93
+ fastExpiry?: boolean;
94
+
95
+ /**
96
+ * PostHog person-property sync (Section 12). Off by default. When set, on
97
+ * join/leave the engine $set/$unset a boolean person property keyed by
98
+ * `postHogPropertyKey` (default `hogsend_bucket_<id>`).
99
+ */
100
+ syncToPostHog?: boolean;
101
+ postHogPropertyKey?: string;
102
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./bucket.js";
1
2
  export * from "./conditions.js";
2
3
  export * from "./journey.js";
3
4
  export * from "./journey-context.js";