@cejel/cejel 0.4.5 → 0.4.7

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.
@@ -4,7 +4,7 @@ const require = __cejelCreateRequire(import.meta.url);
4
4
  import {
5
5
  __export,
6
6
  init_esm_shims
7
- } from "./chunk-R4DPQLS2.js";
7
+ } from "./chunk-ZNVILRHK.js";
8
8
 
9
9
  // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
10
10
  var external_exports = {};
@@ -7,7 +7,7 @@ import {
7
7
  __filename,
8
8
  __require,
9
9
  init_esm_shims
10
- } from "./chunk-R4DPQLS2.js";
10
+ } from "./chunk-ZNVILRHK.js";
11
11
 
12
12
  // node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/typescript.js
13
13
  var require_typescript = __commonJS({
@@ -54,10 +54,17 @@ var init_esm_shims = __esm({
54
54
  }
55
55
  });
56
56
 
57
+ // src/filesystem-limits.ts
58
+ init_esm_shims();
59
+ var MAX_REPOSITORY_CONTENT_BYTES = 512e3;
60
+
57
61
  // src/witan/content-reads.ts
58
62
  init_esm_shims();
59
63
  import { closeSync, lstatSync, openSync, readFileSync, readSync } from "fs";
60
64
  import { resolve } from "path";
65
+ function contentReadSignalKey(criterionId, signalId) {
66
+ return [criterionId, signalId].join(":");
67
+ }
61
68
  var activeSession;
62
69
  function errnoClass(error) {
63
70
  if (typeof error !== "object" || error === null || !("code" in error)) return null;
@@ -69,6 +76,14 @@ function recordSkip(path2, reason, errno, affectsCurrentCriterion = false, dedup
69
76
  if (!session) return;
70
77
  if (affectsCurrentCriterion && session.criterion) {
71
78
  session.affectedCriteria.add(session.criterion);
79
+ const signals = session.signals;
80
+ if (signals && signals.length > 0) {
81
+ for (const signal of signals) {
82
+ session.affectedSignals.add(contentReadSignalKey(session.criterion, signal));
83
+ }
84
+ } else {
85
+ session.unattributedCriteria.add(session.criterion);
86
+ }
72
87
  }
73
88
  if (deduplicate) {
74
89
  const key = `${resolve(path2)}\0${reason}\0${errno ?? ""}`;
@@ -104,7 +119,9 @@ function trackContentReads(_repoPath, collect) {
104
119
  return {
105
120
  value: collect(),
106
121
  summary: summaryFor(existing),
107
- affectedCriteria: existing.affectedCriteria
122
+ affectedCriteria: existing.affectedCriteria,
123
+ affectedSignals: existing.affectedSignals,
124
+ unattributedCriteria: existing.unattributedCriteria
108
125
  };
109
126
  }
110
127
  const session = {
@@ -117,7 +134,9 @@ function trackContentReads(_repoPath, collect) {
117
134
  },
118
135
  unreadableByErrno: /* @__PURE__ */ new Map(),
119
136
  deduplicatedSkips: /* @__PURE__ */ new Set(),
120
- affectedCriteria: /* @__PURE__ */ new Set()
137
+ affectedCriteria: /* @__PURE__ */ new Set(),
138
+ affectedSignals: /* @__PURE__ */ new Set(),
139
+ unattributedCriteria: /* @__PURE__ */ new Set()
121
140
  };
122
141
  activeSession = session;
123
142
  try {
@@ -125,7 +144,9 @@ function trackContentReads(_repoPath, collect) {
125
144
  return {
126
145
  value,
127
146
  summary: summaryFor(session),
128
- affectedCriteria: session.affectedCriteria
147
+ affectedCriteria: session.affectedCriteria,
148
+ affectedSignals: session.affectedSignals,
149
+ unattributedCriteria: session.unattributedCriteria
129
150
  };
130
151
  } finally {
131
152
  activeSession = void 0;
@@ -142,9 +163,36 @@ function withContentReadCriterion(criterion, collect) {
142
163
  session.criterion = previous;
143
164
  }
144
165
  }
166
+ function withContentReadSignal(criterionId, signalId, collect) {
167
+ return withContentReadSignals(criterionId, [signalId], collect);
168
+ }
169
+ function withContentReadSignals(criterionId, signalIds, collect) {
170
+ if (signalIds.length === 0) {
171
+ throw new Error("Cejel invariant: withContentReadSignals requires at least one signal id");
172
+ }
173
+ const session = activeSession;
174
+ if (!session || session.criterion !== criterionId) return collect();
175
+ const previous = session.signals;
176
+ session.signals = signalIds;
177
+ try {
178
+ return collect();
179
+ } finally {
180
+ session.signals = previous;
181
+ }
182
+ }
145
183
  function recordContentSkip(path2, reason, deduplicate = false) {
146
184
  recordSkip(path2, reason, void 0, false, deduplicate);
147
185
  }
186
+ function recordContentSkipForCriteria(path2, reason, criteria, deduplicate = false) {
187
+ const session = activeSession;
188
+ if (session) {
189
+ for (const criterion of criteria) {
190
+ session.affectedCriteria.add(criterion);
191
+ session.unattributedCriteria.add(criterion);
192
+ }
193
+ }
194
+ recordSkip(path2, reason, void 0, false, deduplicate);
195
+ }
148
196
  function recordFilesystemSkip(path2, error, deniedContext = false, deduplicate = true) {
149
197
  const errno = errnoClass(error);
150
198
  if (!errno) throw error;
@@ -161,6 +209,10 @@ function readRepoText(path2, encoding = "utf8") {
161
209
  recordSkip(path2, "non_regular_file", void 0, true, true);
162
210
  return "";
163
211
  }
212
+ if (stat.size > MAX_REPOSITORY_CONTENT_BYTES) {
213
+ recordSkip(path2, "too_large", void 0, true, true);
214
+ return "";
215
+ }
164
216
  } catch (error) {
165
217
  recordFilesystemSkip(path2, error);
166
218
  return "";
@@ -211,9 +263,14 @@ export {
211
263
  __dirname,
212
264
  __filename,
213
265
  init_esm_shims,
266
+ MAX_REPOSITORY_CONTENT_BYTES,
267
+ contentReadSignalKey,
214
268
  trackContentReads,
215
269
  withContentReadCriterion,
270
+ withContentReadSignal,
271
+ withContentReadSignals,
216
272
  recordContentSkip,
273
+ recordContentSkipForCriteria,
217
274
  recordFilesystemSkip,
218
275
  readRepoText,
219
276
  readRepoTextPrefix
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  assertSelectableRubricVersion,
11
11
  buildRelyingPartySummary,
12
12
  createWitanAttestation,
13
+ formatCertificateMetricAppliedWeightPercent,
13
14
  formatCertificateMetricLabel,
14
15
  formatCertificateMetricValue,
15
16
  formatExternalSourceLine,
@@ -20,12 +21,12 @@ import {
20
21
  runCejelScan,
21
22
  serializeWitanReport,
22
23
  verifyWitanAttestationBinding
23
- } from "./chunk-4IXESHG7.js";
24
- import "./chunk-EPK7UTIK.js";
25
- import "./chunk-KGFGX3TP.js";
24
+ } from "./chunk-QTLLASOO.js";
25
+ import "./chunk-OIGCYULH.js";
26
+ import "./chunk-UYJBSQCV.js";
26
27
  import {
27
28
  init_esm_shims
28
- } from "./chunk-R4DPQLS2.js";
29
+ } from "./chunk-ZNVILRHK.js";
29
30
 
30
31
  // src/index.ts
31
32
  init_esm_shims();
@@ -113,13 +114,16 @@ function renderTerminalCertificate(summary, report) {
113
114
  (criterion) => criterion.metrics.map((metric) => ({
114
115
  criterionId: criterion.id,
115
116
  label: formatCertificateMetricLabel(metric),
116
- value: formatCertificateMetricValue(criterion, metric)
117
+ value: formatCertificateMetricValue(criterion, metric),
118
+ weightPercent: formatCertificateMetricAppliedWeightPercent(criterion, metric)
117
119
  }))
118
120
  );
119
121
  if (!abstained && (measurements?.length ?? 0) > 0) {
120
122
  lines.push("Measurements:");
121
123
  for (const measurement of measurements ?? []) {
122
- lines.push(` ${measurement.criterionId} \u2014 ${measurement.label}: ${measurement.value}`);
124
+ lines.push(
125
+ ` ${measurement.criterionId} \u2014 ${measurement.label}: ${measurement.value} (weight ${measurement.weightPercent}% of ${measurement.criterionId})`
126
+ );
123
127
  }
124
128
  lines.push("");
125
129
  }
@@ -210,6 +214,12 @@ var CLI_FLAG_SPECS = [
210
214
  description: "EXPLICIT OPT-IN: pin a rubric other than the calibrated default (see docs); prospective rubrics carry no calibration claim",
211
215
  kind: "rubricPin"
212
216
  },
217
+ {
218
+ tokens: ["--run-attempt"],
219
+ value: "<n>",
220
+ description: "record which CI run attempt produced this certificate (set by the GitHub Action; omit otherwise)",
221
+ kind: "runAttempt"
222
+ },
213
223
  {
214
224
  tokens: ["--quiet"],
215
225
  description: "suppress the terminal summary",
@@ -316,7 +326,11 @@ async function runWitanCli(args, rubricVersion) {
316
326
  ingestPatterns: options.ingestPatterns,
317
327
  warnOnEmptyIngestMatch: !options.quiet
318
328
  });
319
- const attestation = createWitanAttestation(report, { toolVersion: cliVersion(), generatedAt });
329
+ const attestation = createWitanAttestation(report, {
330
+ toolVersion: cliVersion(),
331
+ generatedAt,
332
+ ...options.runAttempt ? { githubRunAttempt: options.runAttempt } : {}
333
+ });
320
334
  mkdirSync(options.outDir, { recursive: true });
321
335
  writeFileSync(join(options.outDir, "report.json"), serializeWitanReport(report), "utf8");
322
336
  writeFileSync(
@@ -326,7 +340,11 @@ async function runWitanCli(args, rubricVersion) {
326
340
  );
327
341
  writeFileSync(
328
342
  join(options.outDir, "certificate.html"),
329
- renderWitanHtmlReport(report, { cliVersion: cliVersion(), generatedAt }),
343
+ renderWitanHtmlReport(report, {
344
+ cliVersion: cliVersion(),
345
+ generatedAt,
346
+ ...options.runAttempt ? { runAttempt: options.runAttempt } : {}
347
+ }),
330
348
  "utf8"
331
349
  );
332
350
  writeFileSync(
@@ -453,6 +471,7 @@ function parseArgs(args) {
453
471
  let showHelp = false;
454
472
  let showVersion = false;
455
473
  let rubricPin;
474
+ let runAttempt;
456
475
  const ingestPatterns = [];
457
476
  for (let index = 0; index < args.length; index += 1) {
458
477
  const arg = args[index];
@@ -531,6 +550,16 @@ function parseArgs(args) {
531
550
  index += 1;
532
551
  break;
533
552
  }
553
+ case "runAttempt": {
554
+ const value = args[index + 1];
555
+ if (!value) throw new Error("Missing value for --run-attempt");
556
+ if (!/^[1-9][0-9]*$/.test(value)) {
557
+ throw new Error(`--run-attempt must be a positive integer, got: ${value}`);
558
+ }
559
+ runAttempt = value;
560
+ index += 1;
561
+ break;
562
+ }
534
563
  }
535
564
  continue;
536
565
  }
@@ -553,7 +582,8 @@ function parseArgs(args) {
553
582
  showHelp,
554
583
  showVersion,
555
584
  ingestPatterns,
556
- ...rubricPin ? { rubricPin } : {}
585
+ ...rubricPin ? { rubricPin } : {},
586
+ ...runAttempt ? { runAttempt } : {}
557
587
  };
558
588
  }
559
589
  function hasUnsafeDisplayNameCharacter(value) {
package/dist/mcp/index.js CHANGED
@@ -5,20 +5,20 @@ import {
5
5
  renderWitanBadgeSvg,
6
6
  renderWitanHtmlReport,
7
7
  runCejelScan
8
- } from "../chunk-4IXESHG7.js";
9
- import "../chunk-EPK7UTIK.js";
8
+ } from "../chunk-QTLLASOO.js";
9
+ import "../chunk-OIGCYULH.js";
10
10
  import {
11
11
  ZodFirstPartyTypeKind,
12
12
  ZodOptional,
13
13
  external_exports,
14
14
  objectType
15
- } from "../chunk-KGFGX3TP.js";
15
+ } from "../chunk-UYJBSQCV.js";
16
16
  import {
17
17
  __commonJS,
18
18
  __export,
19
19
  __toESM,
20
20
  init_esm_shims
21
- } from "../chunk-R4DPQLS2.js";
21
+ } from "../chunk-ZNVILRHK.js";
22
22
 
23
23
  // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
24
24
  var require_code = __commonJS({
@@ -3,18 +3,18 @@ import { createRequire as __cejelCreateRequire } from 'node:module';
3
3
  const require = __cejelCreateRequire(import.meta.url);
4
4
  import {
5
5
  listCejelLlmPackFiles
6
- } from "../../chunk-RW6YJVHZ.js";
6
+ } from "../../chunk-EP7YYWEP.js";
7
7
  import {
8
8
  execGit
9
- } from "../../chunk-EPK7UTIK.js";
9
+ } from "../../chunk-OIGCYULH.js";
10
10
  import {
11
11
  require_typescript
12
- } from "../../chunk-EW6NAHE4.js";
12
+ } from "../../chunk-XHAETB7N.js";
13
13
  import {
14
14
  __toESM,
15
15
  init_esm_shims,
16
16
  readRepoText
17
- } from "../../chunk-R4DPQLS2.js";
17
+ } from "../../chunk-ZNVILRHK.js";
18
18
 
19
19
  // src/packs/d-series/index.ts
20
20
  init_esm_shims();
@@ -3,15 +3,15 @@ import { createRequire as __cejelCreateRequire } from 'node:module';
3
3
  const require = __cejelCreateRequire(import.meta.url);
4
4
  import {
5
5
  external_exports
6
- } from "../../chunk-KGFGX3TP.js";
6
+ } from "../../chunk-UYJBSQCV.js";
7
7
  import {
8
8
  require_typescript
9
- } from "../../chunk-EW6NAHE4.js";
9
+ } from "../../chunk-XHAETB7N.js";
10
10
  import {
11
11
  __toESM,
12
12
  init_esm_shims,
13
13
  readRepoText
14
- } from "../../chunk-R4DPQLS2.js";
14
+ } from "../../chunk-ZNVILRHK.js";
15
15
 
16
16
  // src/packs/decision-contracts/index.ts
17
17
  init_esm_shims();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cejel/cejel",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "mcpName": "io.github.BargLabs/cejel",
5
5
  "private": false,
6
6
  "publishConfig": {