@almadar/std 13.6.0 → 13.7.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.
@@ -18,6 +18,40 @@ type BasicReturnType = 'number' | 'boolean' | 'string' | 'any' | 'void' | 'array
18
18
  /**
19
19
  * Base metadata for an operator.
20
20
  */
21
+ /**
22
+ * For operators whose actual return type depends on input expressions
23
+ * rather than being a fixed primitive (gap #24's family in
24
+ * `docs/Almadar_Std_Verification.md`). The static `returnType` is kept
25
+ * for back-compat with consumers that don't reason about input-dependent
26
+ * types; the validator (L2) reads `returnSemantics` first to derive the
27
+ * concrete type from the call site's argument expressions.
28
+ *
29
+ * - `'first-truthy-of-args'` — returns the first truthy argument's value
30
+ * (`or` semantics, NOT a boolean). Trips arithmetic-context misuse.
31
+ * - `'last-truthy-of-args'` — returns the last truthy argument's value
32
+ * when all are truthy, else first falsy (`and` short-circuit).
33
+ * - `'first-non-null-of-args'` — returns the first non-null arg's type
34
+ * (`coalesce` / `default` / `??`-style).
35
+ * - `'branch-union'` — return type is union of branch result types
36
+ * (`if cond X Y` → `X | Y`).
37
+ * - `'element-of-arg<N>'` — returns element type of arg at index N
38
+ * (`array/first arr` → element of `arr`, `array/get arr i` → element
39
+ * of `arr`). Suffix `?` (e.g. `'element-of-arg<0>?'`) marks
40
+ * nullable-when-missing (`array/find` → `T | undefined`).
41
+ * - `'lambda-result'` — return type is the lambda's body result, with
42
+ * the result possibly wrapped in an array (`array/map` →
43
+ * `Array<ReturnTypeOf<lambda>>`, `array/reduce` →
44
+ * `ReturnTypeOf<lambda>` / type of `init`).
45
+ * - `'object-key-lookup'` — return type depends on the input object
46
+ * shape and the literal key (`object/get`, `object/pick`).
47
+ * - `'identity-of-arg<N>'` — return type matches the input arg at index N
48
+ * (`tap`, `pipe-through`).
49
+ *
50
+ * Operators NOT listed here keep the fixed `returnType` semantics —
51
+ * arithmetic, math, comparisons, aggregations (`array/sum`/`avg`/`len`),
52
+ * type coercions, all effects.
53
+ */
54
+ type ReturnSemantics = 'first-truthy-of-args' | 'last-truthy-of-args' | 'first-non-null-of-args' | 'branch-union' | 'element-of-arg<0>' | 'element-of-arg<0>?' | 'element-of-arg<1>' | 'lambda-result' | 'object-key-lookup' | 'identity-of-arg<0>';
21
55
  interface OperatorMeta {
22
56
  /** Operator category */
23
57
  category: OperatorCategory;
@@ -31,6 +65,15 @@ interface OperatorMeta {
31
65
  hasSideEffects: boolean;
32
66
  /** Return type hint - basic types for core operators, extended types for std modules */
33
67
  returnType: string;
68
+ /**
69
+ * For operators whose actual return type is determined at the call site
70
+ * (input-dependent), tag with the appropriate semantics so the L2
71
+ * validator can derive the concrete type from argument expressions.
72
+ * Omitted when `returnType` is the fixed truth (most operators).
73
+ * See {@link ReturnSemantics} for the catalog and gap #24 in the std
74
+ * verification doc.
75
+ */
76
+ returnSemantics?: ReturnSemantics;
34
77
  }
35
78
  /**
36
79
  * Standard library module names.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/std",
3
- "version": "13.6.0",
3
+ "version": "13.7.0",
4
4
  "description": "Standard library operators for Almadar (math, string, array, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",