wicked-crew 0.7.21 → 0.7.23

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.
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/api/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,EAAmD,WAAW,EAA4E,MAAM,oBAAoB,CAAC;AAG5K,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,KAAK,EAEV,eAAe,EAYf,YAAY,EACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAYtF,OAAO,EAAe,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,aAAa,EAOd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAGL,KAAK,WAAW,EAEhB,KAAK,qBAAqB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,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;IAC3C;;gFAE4E;IAC5E,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,cAAc,CAAC;IAC3D;4FACwF;IACxF,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;mGAC+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAIlC,YAAY,GAAE,WAA+B,EAG7C,QAAQ,GAAE,iBAAqF,EAK/F,QAAQ,GAAE,YAA0D,EAGpE,OAAO,GAAE,WAAgB,GACxB,IAAI,CAs4FN"}
@@ -93,6 +93,39 @@ function invalidBody(err, what) {
93
93
  function firstQueryValue(v) {
94
94
  return Array.isArray(v) ? v[0] : v;
95
95
  }
96
+ /**
97
+ * Parse an optional `since`/`until` date-bound query param (unix SECONDS). Returns the parsed
98
+ * non-negative integer, `undefined` when the param is absent or blank, or the sentinel `'invalid'`
99
+ * when it is present but not a non-negative integer — the caller turns `'invalid'` into a 400 that
100
+ * names the offending param (a silently-dropped bad bound would answer a different date question
101
+ * than the one asked).
102
+ */
103
+ function parseUnixSecondsParam(raw) {
104
+ if (raw === undefined || raw.trim() === '')
105
+ return undefined;
106
+ const n = Number(raw);
107
+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0)
108
+ return 'invalid';
109
+ return n;
110
+ }
111
+ /**
112
+ * Inclusive `[since, until]` date-range predicate (unix seconds) shared by the memory + rules
113
+ * browse filters. An item with NO `created_at` is EXCLUDED whenever either bound is set — an
114
+ * unknown creation time is never asserted in range, and never fabricated (crew never invents a
115
+ * timestamp for a row the store did not stamp). With NEITHER bound set every item passes, so the
116
+ * un-filtered browse is unchanged.
117
+ */
118
+ function withinDateRange(createdAt, since, until) {
119
+ if (since === undefined && until === undefined)
120
+ return true;
121
+ if (typeof createdAt !== 'number')
122
+ return false;
123
+ if (since !== undefined && createdAt < since)
124
+ return false;
125
+ if (until !== undefined && createdAt > until)
126
+ return false;
127
+ return true;
128
+ }
96
129
  /** A JSON object whose every value is a string (a facet/intent tuple, axis→value). */
97
130
  function isStringRecord(v) {
98
131
  return (typeof v === 'object' &&
@@ -136,13 +169,23 @@ export function policyProposalToRule(proposalId, kindType, payload, facets) {
136
169
  };
137
170
  }
138
171
  const rawSeverity = body['severity'];
139
- const severity = rawSeverity === 'info' || rawSeverity === 'warn' || rawSeverity === 'error' || rawSeverity === 'critical'
140
- ? rawSeverity
172
+ // Normalize common LLM drift before the enum check: a model naturally writes the English word
173
+ // "warning", but the engine's enum is the short "warn" (info/error/critical are already the
174
+ // natural words). Tolerate case/whitespace too. A capture worker that says "warning" must still
175
+ // land its policy — otherwise every derived policy at the middle band silently fails to land.
176
+ const normSeverity = typeof rawSeverity === 'string'
177
+ ? (() => {
178
+ const s = rawSeverity.trim().toLowerCase();
179
+ return s === 'warning' ? 'warn' : s;
180
+ })()
181
+ : rawSeverity;
182
+ const severity = normSeverity === 'info' || normSeverity === 'warn' || normSeverity === 'error' || normSeverity === 'critical'
183
+ ? normSeverity
141
184
  : undefined;
142
185
  if (rawSeverity !== undefined && severity === undefined) {
143
186
  return {
144
187
  error: `the approved policy proposal payload has an invalid severity ${JSON.stringify(rawSeverity)} — ` +
145
- 'expected info|warn|error|critical',
188
+ 'expected info|warn|error|critical (or the natural "warning" for warn)',
146
189
  };
147
190
  }
148
191
  const language = facets?.['language'];
@@ -191,6 +234,10 @@ function shapeMemoryItem(raw) {
191
234
  };
192
235
  if (typeof r['score'] === 'number')
193
236
  item.score = r['score'];
237
+ // `created_at` (unix seconds) rides through from estate `memory.list` verbatim — the "added" time
238
+ // the surface date-filters on. Absent on an item the store did not stamp; never fabricated.
239
+ if (typeof r['created_at'] === 'number')
240
+ item.created_at = r['created_at'];
194
241
  return item;
195
242
  }
196
243
  /** Shape the estate `memory.coverage` result (`{ total, by_tier, by_kind }`) into the wire
@@ -2053,6 +2100,27 @@ runtime = {}) {
2053
2100
  return invalid('status', status, 'active|retired|all');
2054
2101
  }
2055
2102
  const layer = facet('layer');
2103
+ // `since`/`until` (unix SECONDS, inclusive) date-bound the listed rows by each rule's
2104
+ // `created_at`. A present-but-non-integer bound is a 400. NOTE: `created_at` is wired-but-
2105
+ // pending a core-ts bump — it landed on the engine's `ConformanceRule` after the published
2106
+ // core-ts this daemon builds against, so on the current binding NO rule carries it and this
2107
+ // filter narrows to empty. The pass-through is verbatim (`listConformanceRules` returns the
2108
+ // parsed rows unchanged), so the bound starts working the moment crew re-pins to a core-ts
2109
+ // that surfaces it — a rule with no `created_at` is excluded, never dated with a fabricated now.
2110
+ const since = facet('since');
2111
+ const sinceSecs = parseUnixSecondsParam(since);
2112
+ if (sinceSecs === 'invalid') {
2113
+ return reply
2114
+ .code(400)
2115
+ .send({ error: `since must be a non-negative integer in unix seconds (got \`${since ?? ''}\`)` });
2116
+ }
2117
+ const until = facet('until');
2118
+ const untilSecs = parseUnixSecondsParam(until);
2119
+ if (untilSecs === 'invalid') {
2120
+ return reply
2121
+ .code(400)
2122
+ .send({ error: `until must be a non-negative integer in unix seconds (got \`${until ?? ''}\`)` });
2123
+ }
2056
2124
  const rules = (await adapter.listConformanceRules()).filter((r) => (severity === undefined || r.severity === severity) &&
2057
2125
  (ruleType === undefined || r.rule_type === ruleType) &&
2058
2126
  (layer === undefined || r.targets.layer === layer) &&
@@ -2060,7 +2128,9 @@ runtime = {}) {
2060
2128
  // steering engine always stamps it, but filter defensively over mixed-era rows.
2061
2129
  (steeringType === undefined || (r.steering_type ?? DEFAULT_STEERING_TYPE) === steeringType) &&
2062
2130
  // `retired` is absent on rows written before the field existed, which read as active.
2063
- (status === 'all' || (status === 'retired') === (r.retired === true)));
2131
+ (status === 'all' || (status === 'retired') === (r.retired === true)) &&
2132
+ // Undated rules (every rule on a pre-bump core-ts) are excluded once a bound is set.
2133
+ withinDateRange(r.created_at, sinceSecs, untilSecs));
2064
2134
  return { rules };
2065
2135
  });
2066
2136
  app.get(`${V}/governance/claims`, async () => {
@@ -2981,6 +3051,18 @@ runtime = {}) {
2981
3051
  }
2982
3052
  limit = n;
2983
3053
  }
3054
+ // `since`/`until` (unix SECONDS, inclusive) date-bound the complete set crew-side by each
3055
+ // memory's `created_at`. A present-but-non-integer bound is a 400 (fail-loud, never a silent
3056
+ // no-filter); a memory with no `created_at` is excluded once either bound is set (see
3057
+ // withinDateRange). Applied BEFORE the row cap, so `limit` cuts the dated set.
3058
+ const since = parseUnixSecondsParam(firstQueryValue(q.since));
3059
+ if (since === 'invalid') {
3060
+ return reply.code(400).send({ error: '`since` must be a non-negative integer (unix seconds)' });
3061
+ }
3062
+ const until = parseUnixSecondsParam(firstQueryValue(q.until));
3063
+ if (until === 'invalid') {
3064
+ return reply.code(400).send({ error: '`until` must be a non-negative integer (unix seconds)' });
3065
+ }
2984
3066
  // `query`, when present, is a case-insensitive CONTENT substring filter over the complete set
2985
3067
  // — a management search that finds faceted memories too (unlike relevance recall).
2986
3068
  const query = (firstQueryValue(q.query) ?? '').trim().toLowerCase();
@@ -2997,6 +3079,9 @@ runtime = {}) {
2997
3079
  const pairs = Object.entries(facetFilter);
2998
3080
  memories = memories.filter((m) => pairs.every(([k, v]) => m.facets[k] === v));
2999
3081
  }
3082
+ if (since !== undefined || until !== undefined) {
3083
+ memories = memories.filter((m) => withinDateRange(m.created_at, since, until));
3084
+ }
3000
3085
  if (limit !== undefined)
3001
3086
  memories = memories.slice(0, limit);
3002
3087
  const body = { memories };