@autotelic/joggle 0.4.3 → 0.4.5

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/JOGGLE.md CHANGED
@@ -421,6 +421,22 @@ Deliberately *not* next: widening AST coverage to class and object-literal
421
421
  methods. That is more surface on a weaker signal. It comes after types.
422
422
 
423
423
 
424
+ ### The committed cache has a size, and it is not free
425
+
426
+ Committing the answer cache buys keyless replay, and it costs bytes in every clone
427
+ and every CI checkout. GitHub warns above **50 MB per file** and refuses above
428
+ 100 MB; a cache is worth nowhere near that.
429
+
430
+ - `joggle cache prune --max-age 90` drops answers nobody has used in a season;
431
+ `joggle cache prune --max-bytes 4000000` caps the file, oldest answers first. Both
432
+ are safe: an answer is regenerable by judging again.
433
+ - A run says so when the store passes 8 MB, because a cache nobody measured is how
434
+ a 0-byte ledger on the base branch becomes 55 MB at the top of a stack.
435
+ - In a stack the growth is per branch: each scoped accept adds this branch's answers
436
+ and the same growing file rides in every commit above it. Cap it before the last
437
+ push, or stop committing it and let a keyed CI judge instead — but only with the
438
+ key, because without one the identities change (see the stack section above).
439
+
424
440
  ## Two committed artifacts, two machine artifacts
425
441
 
426
442
  joggle's state is four files with four lifetimes. Two belong to the repository
@@ -343,6 +343,30 @@ export const make = (fs, path, dir, options = {}) => Effect.gen(function* () {
343
343
  };
344
344
  });
345
345
  const sizeOf = (entry) => renderEntry(entry).length + 1;
346
+ /**
347
+ * How many bytes the ledger occupies on disk, without parsing it.
348
+ *
349
+ * A committed answer cache is a cache, and a cache that only grows is a repository-health
350
+ * problem: GitHub warns above 50 MB per file and refuses above 100 MB, and every clone pays
351
+ * for it. Reading the bytes (rather than the census) keeps the check cheap enough to run on
352
+ * every run, including on a ledger measured in tens of megabytes.
353
+ */
354
+ export const answerStoreBytes = (fs, path, dir) => Effect.gen(function* () {
355
+ const sizeOfFile = (file) => fs.stat(file).pipe(Effect.map((info) => Number(info.size)), Effect.orElseSucceed(() => 0));
356
+ const single = answersFile(path, dir);
357
+ let total = yield* sizeOfFile(single);
358
+ total += yield* sizeOfFile(answersObject(path, dir));
359
+ const shards = answersDir(path, dir);
360
+ const names = yield* fs
361
+ .readDirectory(shards)
362
+ .pipe(Effect.orElseSucceed(() => []));
363
+ for (const name of names) {
364
+ if (!name.endsWith(".jsonl"))
365
+ continue;
366
+ total += yield* sizeOfFile(path.join(shards, name));
367
+ }
368
+ return total;
369
+ });
346
370
  /**
347
371
  * Read the ledger and count what is in it.
348
372
  *
package/dist/check.js CHANGED
@@ -9,6 +9,7 @@ import { shortHash } from "./state.js";
9
9
  import { canonical } from "./canonical.js";
10
10
  import { sourceFingerprint } from "./fingerprint.js";
11
11
  import { loadParses } from "./parsecache.js";
12
+ import { answerStoreBytes } from "./answer-store.js";
12
13
  import { baselinePath, manifestOf, readBaseline, readStored, writeBaseline, writeStored, } from "./run-cache.js";
13
14
  import { policy } from "./policy.js";
14
15
  import { Rules } from "./rules/index.js";
@@ -28,6 +29,14 @@ import { looksLikeSource } from "./source.js";
28
29
  * consequences is a record of something that never happened.
29
30
  */
30
31
  const UNJUDGED_STAGES = new Set(["unreadable", "no_evidence", "budget"]);
32
+ /**
33
+ * The size at which a growing ledger stops being a cache and starts being repository debt.
34
+ *
35
+ * GitHub warns above 50 MB per file and refuses above 100 MB, and every clone and CI
36
+ * checkout pays. Well below that is already larger than a diff anyone reviews, so the note
37
+ * fires early — at 8 MB — and names the cap rather than waiting for the warning.
38
+ */
39
+ const CACHE_WARN_BYTES = 8 * 1024 * 1024;
31
40
  const reasonOf = (error) => error.message;
32
41
  const typecheckFindings = (output) => output.map((diagnostic) => finding({
33
42
  ruleId: "joggle/typecheck",
@@ -250,6 +259,17 @@ export const checkRepository = Effect.fn("joggle.check")(function* (options) {
250
259
  reason: `wrote 0 identities to ${target}: nothing new to accept`,
251
260
  });
252
261
  }
262
+ // A finding with no identity is one no baseline can ever hold: it survives every run
263
+ // and no accept quiets it. Saying so is the difference between "accepted" and
264
+ // "accepted, and these will be back".
265
+ const unnameable = report.diagnostics.filter((entry) => entry.identity === undefined).length;
266
+ if (unnameable > 0) {
267
+ notes.push({
268
+ ruleId: "joggle",
269
+ reason: unnameable +
270
+ " finding(s) declare no identity, so no baseline can accept them; they will appear in every run",
271
+ });
272
+ }
253
273
  }
254
274
  return notes.length === 0
255
275
  ? { ...report, diagnostics }
@@ -836,6 +856,19 @@ export const checkRepository = Effect.fn("joggle.check")(function* (options) {
836
856
  : "; a folded finding's identity is not in this run, so an accept taken from a scoped run can miss one a full run reports"),
837
857
  });
838
858
  }
859
+ // A committed answer cache is a cache, and a cache that only grows is a repository-health
860
+ // problem the run can see: GitHub warns above 50 MB per file and refuses above 100 MB, and
861
+ // every clone and CI checkout pays for the bytes. Scoped accepts on a deep stack grow it
862
+ // fastest, because each branch judges its own delta and keeps every answer.
863
+ const cacheBytes = yield* answerStoreBytes(fs, path, options.cacheDir);
864
+ if (cacheBytes > CACHE_WARN_BYTES) {
865
+ const megabytes = Math.round((cacheBytes / (1024 * 1024)) * 10) / 10;
866
+ notes.push({
867
+ ruleId: "joggle",
868
+ reason: `the judgement cache at ${options.cacheDir} is ${megabytes} MB; keep it machine-local or cap what is committed (` +
869
+ "joggle cache prune --max-bytes 4000000) — GitHub warns above 50 MB per file and every clone pays for it",
870
+ });
871
+ }
839
872
  // The workspace's own phases, alongside the per-rule timings. A run that says
840
873
  // "workspace 4.4s" and nothing else is a run nobody can make faster.
841
874
  timings.push(...workspace.phases);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autotelic/joggle",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "Cross-file patterns and idioms for TypeScript — the layer above the linter and the typechecker.",
6
6
  "license": "MIT",