@autotelic/joggle 0.8.1 → 0.8.2
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/dist/check.js +6 -3
- package/dist/decision.js +2 -1
- package/dist/main.js +2 -1
- package/dist/policy.js +16 -5
- package/dist/rules/single-path.js +3 -1
- package/dist/rules/types-over-logic.js +3 -1
- package/dist/run-cache.js +2 -1
- package/dist/version.js +23 -0
- package/dist/version.test.js +18 -0
- package/package.json +1 -1
package/dist/check.js
CHANGED
|
@@ -12,6 +12,7 @@ import { loadParses } from "./parsecache.js";
|
|
|
12
12
|
import { answerStoreBytes } from "./answer-store.js";
|
|
13
13
|
import { baselinePath, manifestOf, readBaseline, readStored, writeBaseline, writeStored, } from "./run-cache.js";
|
|
14
14
|
import { policy } from "./policy.js";
|
|
15
|
+
import { VERSION } from "./version.js";
|
|
15
16
|
import { Rules } from "./rules/index.js";
|
|
16
17
|
import { foldSiteDuplicates, funnelNotes, rankDiagnostics } from "./report.js";
|
|
17
18
|
import { countUnjudged, everyFile, finding, inGraphScope, outcome, } from "./rule.js";
|
|
@@ -246,8 +247,10 @@ export const checkRepository = Effect.fn("joggle.check")(function* (options) {
|
|
|
246
247
|
cause: new Error(`refusing to write ${options.updateBaselinePath}: ${unjudged} candidate(s) were not judged. ` +
|
|
247
248
|
"Judging needs a model key in this run's environment (TYPESAFE_API_KEY); without one, " +
|
|
248
249
|
"the same findings are named from what the rule could see alone, so a ledger written " +
|
|
249
|
-
"now would not match a judged run. Judge first
|
|
250
|
-
"
|
|
250
|
+
"now would not match a judged run. Judge first; if the limit was the run's token " +
|
|
251
|
+
"budget, raise --max-tokens or decision.maxInputTokens. A per-rule candidate " +
|
|
252
|
+
"ceiling is not that knob, and the report names the rule whose ceiling it was. " +
|
|
253
|
+
"Or run scoped (--since <base>) to see the change judged with a pull " +
|
|
251
254
|
"request's budget — a scoped run reports the gate's answer but cannot write the " +
|
|
252
255
|
"ledger. Pass --allow-unjudged-baseline only to accept the unjudged debt itself."),
|
|
253
256
|
});
|
|
@@ -960,7 +963,7 @@ export const checkRepository = Effect.fn("joggle.check")(function* (options) {
|
|
|
960
963
|
// next full run is compared against.
|
|
961
964
|
if (!options.changed && options.changedPaths === undefined) {
|
|
962
965
|
yield* writeStored(fs, path, runCache, {
|
|
963
|
-
version:
|
|
966
|
+
version: VERSION,
|
|
964
967
|
manifest,
|
|
965
968
|
sources: workspace.files.map((file) => ({
|
|
966
969
|
path: file.path,
|
package/dist/decision.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Decision, DecisionModel } from "effect/ai";
|
|
|
4
4
|
import { TypeSafeClient, TypeSafeDecisionModel, TypeSafeSchema } from "@effect/ai-typesafe";
|
|
5
5
|
import { canonical } from "./canonical.js";
|
|
6
6
|
import { policy } from "./policy.js";
|
|
7
|
+
import { VERSION } from "./version.js";
|
|
7
8
|
import { make as makeAnswerStore } from "./answer-store.js";
|
|
8
9
|
import { answerOf, memoize, PlanAnswers, storedOf } from "./plans.js";
|
|
9
10
|
// The judged half of joggle, as Effect's own DecisionModel.
|
|
@@ -123,7 +124,7 @@ export const layer = (options) => Layer.effectContext(Effect.gen(function* () {
|
|
|
123
124
|
const writer = yield* Semaphore.make(1);
|
|
124
125
|
const flush = writer.withPermits(1)(Effect.gen(function* () {
|
|
125
126
|
const current = yield* Ref.get(entries);
|
|
126
|
-
const body = JSON.stringify({ version:
|
|
127
|
+
const body = JSON.stringify({ version: VERSION, entries: current }, null, 2);
|
|
127
128
|
yield* Effect.orElseSucceed(fs.makeDirectory(options.cacheDir, { recursive: true }), () => undefined);
|
|
128
129
|
yield* Effect.orElseSucceed(fs.writeFileString(file, body), () => undefined);
|
|
129
130
|
}));
|
package/dist/main.js
CHANGED
|
@@ -13,6 +13,7 @@ import { loadConfig, isEnabled, severityFor } from "./config.js";
|
|
|
13
13
|
import { layer as gitLayer, Service as Git } from "./git.js";
|
|
14
14
|
import { loadPlugins, withDefaults } from "./plugins.js";
|
|
15
15
|
import { policy } from "./policy.js";
|
|
16
|
+
import { VERSION } from "./version.js";
|
|
16
17
|
import { exitCodeFor, render } from "./report.js";
|
|
17
18
|
import { applyDeclarationTypes, isRecord, loadWorkspace } from "./workspace.js";
|
|
18
19
|
import { answerPlansRaw, chunkPlans } from "./plans.js";
|
|
@@ -691,7 +692,7 @@ const cli = Command.make("joggle").pipe(Command.withDescription("Cross-file patt
|
|
|
691
692
|
{ command: "joggle rules", description: "See what is enforced here." },
|
|
692
693
|
]), Command.withSubcommands([checkCommand, askCommand, rules, calibrateCommand, cacheCommand, mergeAnswers]));
|
|
693
694
|
const services = Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer, builtIn);
|
|
694
|
-
const program = Command.run(cli, { version:
|
|
695
|
+
const program = Command.run(cli, { version: VERSION }).pipe(Effect.provide(services));
|
|
695
696
|
/*
|
|
696
697
|
* Never fail silently. A typed failure, an interruption and a defect all have
|
|
697
698
|
* to reach stderr with enough detail to act on. This is a CI gate, and a gate
|
package/dist/policy.js
CHANGED
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
* candidates is the code's.
|
|
15
15
|
*/
|
|
16
16
|
export const policy = {
|
|
17
|
-
/** Surfaced by `joggle --version`. */
|
|
18
|
-
version: "0.1.0",
|
|
19
17
|
/** The System One model every rule judges with. */
|
|
20
18
|
model: "jev-latest",
|
|
21
19
|
/**
|
|
@@ -465,7 +463,13 @@ export const policy = {
|
|
|
465
463
|
* repository rather than a budget anybody should reach.
|
|
466
464
|
*/
|
|
467
465
|
docMatchesCode: {
|
|
468
|
-
|
|
466
|
+
/**
|
|
467
|
+
* Measured, not guessed: this workspace has 679 documented declarations, and at 400 the
|
|
468
|
+
* overflow was 279 candidates that no run could ever judge — the slice is deterministic,
|
|
469
|
+
* so a second run asks the same 400 again. A baseline that refuses to be written while
|
|
470
|
+
* candidates are unjudged cannot exist for a repository this size at that ceiling.
|
|
471
|
+
*/
|
|
472
|
+
maxDeclarations: 1000,
|
|
469
473
|
/** Tokens below which a declaration has nothing for a doc to describe. */
|
|
470
474
|
minTokens: 40,
|
|
471
475
|
},
|
|
@@ -650,8 +654,15 @@ export const policy = {
|
|
|
650
654
|
* one run may judge, and how much evidence one candidate may carry.
|
|
651
655
|
*/
|
|
652
656
|
strata: {
|
|
653
|
-
/**
|
|
654
|
-
|
|
657
|
+
/**
|
|
658
|
+
* Candidates one strata rule may judge in a run.
|
|
659
|
+
*
|
|
660
|
+
* 200 was a ceiling against a pathological repository, and this ordinary one reached it:
|
|
661
|
+
* `declared-staleness` had 538 projections (338 over) and `invariant-has-a-reconciler`
|
|
662
|
+
* 289 checks (89 over). The slice is deterministic, so the overflow was permanent rather
|
|
663
|
+
* than deferred to a later run.
|
|
664
|
+
*/
|
|
665
|
+
maxCandidates: 1000,
|
|
655
666
|
/** Fields two structures must share before their overlap is worth a question. */
|
|
656
667
|
minSharedFields: 3,
|
|
657
668
|
/** Tokens a function needs before a table read can be a check rather than a getter. */
|
|
@@ -111,7 +111,9 @@ export const singlePath = {
|
|
|
111
111
|
]),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
// 16 members' worth of sites was 192 on this workspace, which has 408 string sites --
|
|
115
|
+
// 216 candidates sliced off every run. 64 members' worth (768) fits the measured tree.
|
|
116
|
+
const budget = policy.evidence.maxMembers * 64;
|
|
115
117
|
const judged = candidates.slice(0, budget);
|
|
116
118
|
const overBudget = candidates.slice(budget).map((candidate) => ({
|
|
117
119
|
ruleId: RULE_ID,
|
|
@@ -90,7 +90,9 @@ export const typesOverLogic = {
|
|
|
90
90
|
]),
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
// The same measured ceiling as `single-path`: a 12-member evidence window times 16 was
|
|
94
|
+
// 192 guards, and a real workspace exceeds it. 64 keeps the bound without truncating.
|
|
95
|
+
const budget = policy.evidence.maxMembers * 64;
|
|
94
96
|
const judged = candidates.slice(0, budget);
|
|
95
97
|
const overBudget = candidates.slice(budget).map((candidate) => ({
|
|
96
98
|
ruleId: RULE_ID,
|
package/dist/run-cache.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect, FileSystem, Path, Result, Schema, SchemaParser } from "effect";
|
|
2
2
|
import { policy } from "./policy.js";
|
|
3
|
+
import { VERSION } from "./version.js";
|
|
3
4
|
import { shortHash } from "./state.js";
|
|
4
5
|
import { Baseline, StoredRun } from "./schema.js";
|
|
5
6
|
/**
|
|
@@ -110,7 +111,7 @@ export const writeBaseline = (fs, path, target, identities) => Effect.gen(functi
|
|
|
110
111
|
yield* Effect.orElseSucceed(fs.makeDirectory(parent, { recursive: true }), () => undefined);
|
|
111
112
|
// A ledger is a set: a merge that re-accepts an identity must not grow a duplicate row.
|
|
112
113
|
const body = JSON.stringify({
|
|
113
|
-
version:
|
|
114
|
+
version: VERSION,
|
|
114
115
|
identities: [...new Set(identities)].sort((left, right) => left.localeCompare(right)),
|
|
115
116
|
}, null, 2);
|
|
116
117
|
yield* Effect.orElseSucceed(fs.writeFileString(target, body), () => undefined);
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { Result, Schema, SchemaParser } from "effect";
|
|
4
|
+
/*
|
|
5
|
+
* The version this build actually is.
|
|
6
|
+
*
|
|
7
|
+
* `policy.version` held a hand-typed "0.1.0" while the package reached 0.8.1, and
|
|
8
|
+
* `joggle --version` printed it. A consumer comparing versions to prove a fix arrived read
|
|
9
|
+
* a number that never moved; so did every cache document that stamped it. The manifest is
|
|
10
|
+
* the one place a release writes, so the tool reads it instead of repeating it.
|
|
11
|
+
*
|
|
12
|
+
* Two path shapes resolve to the same file: `dist/version.js` and `src/version.ts` both sit
|
|
13
|
+
* one directory below the package root. A build that cannot read its own manifest reports
|
|
14
|
+
* 0.0.0 rather than failing, because the version is a label on a report, not an input to it.
|
|
15
|
+
*/
|
|
16
|
+
const Packaged = Schema.Struct({ version: Schema.String });
|
|
17
|
+
const readVersion = () => {
|
|
18
|
+
const file = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
19
|
+
const text = Result.getOrElse(Result.try(() => readFileSync(file, "utf8")), () => "");
|
|
20
|
+
const decoded = Result.getOrUndefined(SchemaParser.decodeResult(Schema.fromJsonString(Packaged))(text));
|
|
21
|
+
return decoded?.version ?? "0.0.0";
|
|
22
|
+
};
|
|
23
|
+
export const VERSION = readVersion();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { Result, Schema, SchemaParser } from "effect";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { VERSION } from "./version.js";
|
|
5
|
+
/*
|
|
6
|
+
* The label a consumer compares against npm.
|
|
7
|
+
*
|
|
8
|
+
* It was a constant, and the constant stopped moving while the package kept releasing. The
|
|
9
|
+
* claim worth pinning is not the string — it is that the string is the manifest's.
|
|
10
|
+
*/
|
|
11
|
+
describe("VERSION", () => {
|
|
12
|
+
it("is the version in the package manifest", () => {
|
|
13
|
+
const Packaged = Schema.Struct({ version: Schema.String });
|
|
14
|
+
const manifest = Result.getOrThrow(SchemaParser.decodeResult(Schema.fromJsonString(Packaged))(readFileSync(new URL("../package.json", import.meta.url), "utf8")));
|
|
15
|
+
expect(VERSION).toBe(manifest.version);
|
|
16
|
+
expect(VERSION).not.toBe("0.0.0");
|
|
17
|
+
});
|
|
18
|
+
});
|