@mark1russell7/canon-ontology 0.2.0 → 0.3.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.
- package/build/index.d.mts +2 -2
- package/build/index.mjs +21 -2
- package/build/index.mjs.map +1 -1
- package/build/{targets-DsUgzuOM.mjs → targets-BwC2nZGy.mjs} +57 -2
- package/build/targets-BwC2nZGy.mjs.map +1 -0
- package/build/{targets-DkEkvgll.d.mts → targets-D3vj1inS.d.mts} +35 -1
- package/build/targets.d.mts +2 -2
- package/build/targets.mjs +1 -1
- package/package.json +1 -1
- package/build/targets-DsUgzuOM.mjs.map +0 -1
|
@@ -315,6 +315,61 @@ function resultClaimsOf(ontology) {
|
|
|
315
315
|
function claimFails(claim) {
|
|
316
316
|
return claim.state === "not checked" || claim.kind === "status" && claim.state === "partial";
|
|
317
317
|
}
|
|
318
|
+
// src/problems.ts
|
|
319
|
+
/**
|
|
320
|
+
* This function gives the key of a Lean name: the name with no `«` and `»` quotes. The board name
|
|
321
|
+
* `Kourovka.20.51.kourovka_20_51` and the Lean name `Kourovka.«20.51».kourovka_20_51` have one key.
|
|
322
|
+
*/
|
|
323
|
+
function leanKey(name) {
|
|
324
|
+
return name.trim().replace(/[«»]/g, "");
|
|
325
|
+
}
|
|
326
|
+
/** This function gives the Lean key of the formal statement of a record, or `undefined` when the record has none. */
|
|
327
|
+
function formalKeyOf(record) {
|
|
328
|
+
const formal = record.attrs["formal"];
|
|
329
|
+
return typeof formal === "string" && formal.trim() !== "" ? leanKey(formal) : void 0;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* This function gives the id of a live problem. The problem has the id `name`, or its formal statement has the Lean key
|
|
333
|
+
* of `name`. The function gives `undefined` when no live problem has the name. A page can use it with no Node.js.
|
|
334
|
+
*/
|
|
335
|
+
function problemIdOf(records, name) {
|
|
336
|
+
const id = name.trim();
|
|
337
|
+
const key = leanKey(name);
|
|
338
|
+
for (const record of records) if (record.kind === "problem" && isLive(record) && (record.id === id || formalKeyOf(record) === key)) return record.id;
|
|
339
|
+
}
|
|
340
|
+
/** This function finds the live problem with the name `name`, as `problemIdOf` does, and its live results. */
|
|
341
|
+
function findProblem(ontology, name) {
|
|
342
|
+
const id = problemIdOf(ontology.records.map(({ record }) => record), name);
|
|
343
|
+
const found = id === void 0 ? void 0 : ontology.records.find(({ record }) => record.id === id);
|
|
344
|
+
if (found === void 0) return void 0;
|
|
345
|
+
const { record: problem, path } = found;
|
|
346
|
+
const entries = new Map(ontology.records.map((entry) => [entry.record.id, entry]));
|
|
347
|
+
const about = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const edge of edgesOf(ontology)) {
|
|
349
|
+
if (edge.type !== "about" || !isLive(edge)) continue;
|
|
350
|
+
const set = about.get(edge.from) ?? /* @__PURE__ */ new Set();
|
|
351
|
+
set.add(edge.to);
|
|
352
|
+
about.set(edge.from, set);
|
|
353
|
+
}
|
|
354
|
+
const results = [];
|
|
355
|
+
for (const [from, targets] of about) {
|
|
356
|
+
const entry = entries.get(from);
|
|
357
|
+
if (entry?.record.kind !== "result" || !isLive(entry.record) || !targets.has(problem.id)) continue;
|
|
358
|
+
const scope = scopeOf(entry.record);
|
|
359
|
+
results.push({
|
|
360
|
+
id: from,
|
|
361
|
+
path: entry.path,
|
|
362
|
+
scope: scope === void 0 ? "" : scopeText(scope),
|
|
363
|
+
full: hasFullScope(entry.record, problem),
|
|
364
|
+
about: [...targets].filter((to) => to !== problem.id).sort()
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
problem,
|
|
369
|
+
path,
|
|
370
|
+
results: results.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
318
373
|
// src/targets.ts
|
|
319
374
|
/** The sizes, the smallest first. */
|
|
320
375
|
const SIZES = [
|
|
@@ -872,6 +927,6 @@ function targetsOf(ontology) {
|
|
|
872
927
|
}))
|
|
873
928
|
})).sort(compareTargets);
|
|
874
929
|
}
|
|
875
|
-
export {
|
|
930
|
+
export { GRAMMAR_FILE as A, scopeText as C, kindOf as D, isLive as E, makeId as F, npmPackageId as I, npmPurl as L, RECORD_SCHEMA_FILE as M, idPart as N, lineageOf as O, kindOfId as P, pathOfId as R, sameScope as S, isKindIn as T, scopeOf as _, SIZES as a, inScope as b, targetsOf as c, leanKey as d, problemIdOf as f, resultClaimsOf as g, hasFullScope as h, PLACES_SHOWN as i, ONTOLOGY_FOLDER as j, relationOf as k, findProblem as l, claimFails as m, NECESSARY_GATES as n, compareTargets as o, CLAIM_STATUSES as p, ONTOLOGY_REPOSITORY as r, targetId as s, MAP_PACKAGE as t, formalKeyOf as u, SCOPE_MODULUS_LIMIT as v, edgesOf as w, readScope as x, canonicalScope as y, repositoryId as z };
|
|
876
931
|
|
|
877
|
-
//# sourceMappingURL=targets-
|
|
932
|
+
//# sourceMappingURL=targets-BwC2nZGy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets-BwC2nZGy.mjs","names":[],"sources":["../src/ids.ts","../src/grammar.ts","../src/scope.ts","../src/results.ts","../src/problems.ts","../src/targets.ts"],"sourcesContent":["// The ids of the records and the paths of their files.\nimport { formatPurl } from \"@mark1russell7/package-id\";\n\n/** The folder of the record files, relative to the root of the repository. */\nexport const ONTOLOGY_FOLDER = \"ontology\";\n\n/** The file of the grammar, relative to the root of the repository. */\nexport const GRAMMAR_FILE = \"schema/grammar.json\";\n\n/** The file of the JSON Schema of one record file, relative to the root of the repository. */\nexport const RECORD_SCHEMA_FILE = \"schema/record.schema.json\";\n\n/**\n * This function gives one part of an id from a name. The part is in lower case. A hyphen goes before each upper-case\n * letter that follows a lower-case letter or a digit. One hyphen replaces each run of other characters. For example,\n * `greatCircleKm` gives `great-circle-km`, and `@mark1russell7/text` gives `mark1russell7-text`.\n */\nexport function idPart(name: string): string {\n const words = name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n return words.replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n}\n\n/** This function gives an id from a kind and the parts of a name. Each part goes through `idPart`. */\nexport function makeId(kind: string, ...parts: readonly string[]): string {\n return [kind, ...parts.map(idPart)].join(\".\");\n}\n\n/** This function gives the kind at the start of an id: the text before the first dot. */\nexport function kindOfId(id: string): string {\n const dot = id.indexOf(\".\");\n return dot < 0 ? id : id.slice(0, dot);\n}\n\n/**\n * This function gives the path of the file of a record, relative to the root of the repository. The path is the folder\n * of its kind, then the rest of the id. For example, `area.statistics` is in `ontology/area/statistics.json`.\n */\nexport function pathOfId(id: string): string {\n const kind = kindOfId(id);\n return `${ONTOLOGY_FOLDER}/${kind}/${id.slice(kind.length + 1)}.json`;\n}\n\n/** This function gives the id of the repository `owner/name`. */\nexport function repositoryId(owner: string, name: string): string {\n return makeId(\"repository\", owner, name);\n}\n\n/** This function gives the id of the npm package `name`. A scoped name gives the scope and the name as two parts. */\nexport function npmPackageId(name: string): string {\n const scoped = /^@([^/]+)\\/(.+)$/.exec(name);\n return scoped === null ? makeId(\"package\", \"npm\", name) : makeId(\"package\", \"npm\", scoped[1] ?? \"\", scoped[2] ?? \"\");\n}\n\n/** This function gives the package URL of the npm package `name`, as the purl specification writes it. */\nexport function npmPurl(name: string): string {\n const scoped = /^(@[^/]+)\\/(.+)$/.exec(name);\n const purl = scoped === null ? { type: \"npm\", name } : { type: \"npm\", namespace: scoped[1] ?? \"\", name: scoped[2] ?? \"\" };\n const text = formatPurl(purl);\n if (text === undefined) throw new Error(`The npm name ${name} gives no package URL.`);\n return text;\n}\n","// The queries over the grammar: the kinds, their ancestors and the relation kinds.\nimport type { Edge, Envelope, Grammar, KindDef, Ontology, RelationKindDef } from \"./types.ts\";\n\n/** This function gives the kind with the name `name`, or undefined. */\nexport function kindOf(grammar: Grammar, name: string): KindDef | undefined {\n return grammar.kinds.find((kind) => kind.name === name);\n}\n\n/** This function gives the relation kind with the name `name`, or undefined. */\nexport function relationOf(grammar: Grammar, name: string): RelationKindDef | undefined {\n return grammar.relations.find((relation) => relation.name === name);\n}\n\n/**\n * This function gives the kind `name` and each ancestor kind, the nearest first. A loop of parents ends the list at the\n * first kind that comes again. A kind that the grammar does not have gives an empty list.\n */\nexport function lineageOf(grammar: Grammar, name: string): readonly string[] {\n const lineage: string[] = [];\n let kind = kindOf(grammar, name);\n while (kind !== undefined && !lineage.includes(kind.name)) {\n lineage.push(kind.name);\n kind = kind.parent === null ? undefined : kindOf(grammar, kind.parent);\n }\n return lineage;\n}\n\n/** This function tells if a record of the kind `name` is also a record of one of the kinds `allowed`. */\nexport function isKindIn(grammar: Grammar, name: string, allowed: readonly string[]): boolean {\n return lineageOf(grammar, name).some((kind) => allowed.includes(kind));\n}\n\n/** This function gives each relation of the ontology with its two ends, in the order of the record files. */\nexport function edgesOf(ontology: Ontology): readonly Edge[] {\n return ontology.records.flatMap(({ record }) =>\n (record.edges ?? []).map((edge) => ({\n from: record.id,\n type: edge.type,\n to: edge.to,\n qualifiers: edge.qualifiers ?? {},\n envelope: edge.envelope ?? {},\n })),\n );\n}\n\n/** This function tells if a relation or a record is live: no other record supersedes it, and nobody retired it. */\nexport function isLive(item: { readonly envelope?: Envelope | undefined }): boolean {\n return item.envelope?.superseded_by === undefined && item.envelope?.retired_from === undefined;\n}\n","// The scope of a claim: the values of one integer variable that a result settles, or that the statement of a problem\n// covers (roadmap C16). A target closes only when the scope of a checked claim equals the scope of its problem. A result\n// of another scope is a partial claim: the target shows it, and the target stays open.\nimport { isRecord } from \"@mark1russell7/optional/read\";\nimport { sorted } from \"@mark1russell7/rigor-statistics\";\n\n/** The largest modulus of a scope. A scope lists its residues, so a larger modulus gives a record that is too long. */\nexport const SCOPE_MODULUS_LIMIT = 1_000_000;\n\n/**\n * A scope is a set of integers. A value v of `variable` is in the set when three conditions are true. `from` ≤ v. When\n * `to` has a value, v ≤ `to`. The residue v mod `modulus` is in `residues`.\n */\nexport interface Scope {\n readonly variable: string;\n readonly from: bigint;\n readonly to: bigint | undefined;\n /** This value is 1 when the scope has no class condition. */\n readonly modulus: number;\n /** These values are the residues modulo `modulus`, the least first, each once. */\n readonly residues: readonly number[];\n}\n\nconst INTEGER = /^-?(0|[1-9][0-9]*)$/;\nconst VARIABLE = /^[a-z][a-z0-9]*$/;\n\nfunction readBound(value: unknown, name: string): bigint | string {\n return typeof value === \"string\" && INTEGER.test(value) ? BigInt(value) : `The field ${name} of the scope is not an integer as a decimal text.`;\n}\n\nfunction readResidues(value: unknown, name: string, modulus: number): number[] | string {\n if (!Array.isArray(value) || value.length === 0) return `The field ${name} of the scope is not a list of residues.`;\n const seen = new Set<number>();\n for (const residue of value) {\n if (!Number.isSafeInteger(residue) || (residue as number) < 0 || (residue as number) >= modulus) return `The field ${name} of the scope has ${JSON.stringify(residue)}, which is not a residue from 0 to ${String(modulus - 1)}.`;\n if (seen.has(residue as number)) return `The field ${name} of the scope has ${String(residue)} two times.`;\n seen.add(residue as number);\n }\n return sorted([...seen]);\n}\n\n/**\n * This function reads the JSON form of a scope. The form has `variable`, `from` and optionally `to`, with the bounds as\n * decimal texts. It can also have `modulus` with one of `residues` and `except`. The function gives the scope, or the\n * text of the problem.\n */\nexport function readScope(value: unknown): Scope | string {\n if (!isRecord(value)) return \"The scope is not an object.\";\n const variable = value[\"variable\"];\n if (typeof variable !== \"string\" || !VARIABLE.test(variable)) return \"The field variable of the scope is not a name.\";\n const from = readBound(value[\"from\"], \"from\");\n if (typeof from === \"string\") return from;\n const to = value[\"to\"] === undefined ? undefined : readBound(value[\"to\"], \"to\");\n if (typeof to === \"string\") return to;\n if (to !== undefined && to < from) return \"The field to of the scope is less than the field from.\";\n const modulusValue = value[\"modulus\"];\n if (modulusValue === undefined) {\n if (value[\"residues\"] !== undefined || value[\"except\"] !== undefined) return \"The scope has residues but no modulus.\";\n return { variable, from, to, modulus: 1, residues: [0] };\n }\n if (!Number.isSafeInteger(modulusValue) || (modulusValue as number) < 1 || (modulusValue as number) > SCOPE_MODULUS_LIMIT) {\n return `The field modulus of the scope is not an integer from 1 to ${String(SCOPE_MODULUS_LIMIT)}.`;\n }\n const modulus = modulusValue as number;\n if ((value[\"residues\"] === undefined) === (value[\"except\"] === undefined)) return \"The scope with a modulus has one of residues and except.\";\n if (value[\"residues\"] !== undefined) {\n const residues = readResidues(value[\"residues\"], \"residues\", modulus);\n return typeof residues === \"string\" ? residues : { variable, from, to, modulus, residues };\n }\n const except = readResidues(value[\"except\"], \"except\", modulus);\n if (typeof except === \"string\") return except;\n const out = new Set(except);\n const residues = Array.from({ length: modulus }, (_, r) => r).filter((r) => !out.has(r));\n return residues.length === 0 ? \"The field except of the scope has each residue, so the scope is empty.\" : { variable, from, to, modulus, residues };\n}\n\nfunction residueOf(value: bigint, modulus: number): number {\n const m = BigInt(modulus);\n return Number(((value % m) + m) % m);\n}\n\n/** This function gives the least modulus d of the classes: the residues modulo the modulus repeat with the period d. */\nfunction leastPeriod(modulus: number, residues: ReadonlySet<number>): number {\n for (let d = 1; d < modulus; d++) {\n if (modulus % d !== 0) continue;\n if ([...residues].every((r) => residues.has((r + d) % modulus))) return d;\n }\n return modulus;\n}\n\n/**\n * This function gives the canonical form of a scope, or `undefined` for an empty scope. The canonical form has the\n * least modulus of its classes. Its `from` and `to` are values of the set.\n */\nexport function canonicalScope(scope: Scope): Scope | undefined {\n const all = new Set(scope.residues.map((r) => ((r % scope.modulus) + scope.modulus) % scope.modulus));\n if (all.size === 0) return undefined;\n const modulus = leastPeriod(scope.modulus, all);\n const residues = sorted([...new Set([...all].map((r) => r % modulus))]);\n const set = new Set(residues);\n let step = 0;\n while (!set.has((residueOf(scope.from, modulus) + step) % modulus)) step++;\n const from = scope.from + BigInt(step);\n let to: bigint | undefined;\n if (scope.to !== undefined) {\n step = 0;\n while (!set.has((residueOf(scope.to, modulus) - step + modulus) % modulus)) step++;\n to = scope.to - BigInt(step);\n if (to < from) return undefined;\n }\n return { variable: scope.variable, from, to, modulus, residues };\n}\n\n/**\n * This function tells if two scopes have the same canonical form. Two equal unbounded sets have the same form. Two\n * equal bounded sets can have different classes, and then the function gives `false`. So a claim of a short range\n * keeps its target open, and a wrong `true` cannot close a target.\n */\nexport function sameScope(a: Scope, b: Scope): boolean {\n const x = canonicalScope(a);\n const y = canonicalScope(b);\n if (x === undefined || y === undefined) return false;\n return (\n x.variable === y.variable &&\n x.from === y.from &&\n x.to === y.to &&\n x.modulus === y.modulus &&\n x.residues.length === y.residues.length &&\n x.residues.every((r, i) => r === y.residues[i])\n );\n}\n\n/** This function tells if a value is in a scope. */\nexport function inScope(scope: Scope, value: bigint): boolean {\n return value >= scope.from && (scope.to === undefined || value <= scope.to) && scope.residues.includes(residueOf(value, scope.modulus));\n}\n\n/** The most residues that the text of a scope shows. */\nconst SHOWN_RESIDUES = 8;\n\nfunction residueText(residues: readonly number[]): string {\n const shown = residues.slice(0, SHOWN_RESIDUES).join(\", \");\n return residues.length > SHOWN_RESIDUES ? `{${shown} and ${String(residues.length - SHOWN_RESIDUES)} more}` : `{${shown}}`;\n}\n\n/** This function gives the scope in words, for example `n ≥ 3, n mod 840 not in {1, 121}`. */\nexport function scopeText(scope: Scope): string {\n const v = scope.variable;\n const range = scope.to === undefined ? `${v} ≥ ${String(scope.from)}` : `${String(scope.from)} ≤ ${v} ≤ ${String(scope.to)}`;\n if (scope.modulus === 1) return range;\n const has = new Set(scope.residues);\n const missing = Array.from({ length: scope.modulus }, (_, r) => r).filter((r) => !has.has(r));\n return missing.length < scope.residues.length\n ? `${range}, ${v} mod ${String(scope.modulus)} not in ${residueText(missing)}`\n : `${range}, ${v} mod ${String(scope.modulus)} in ${residueText(scope.residues)}`;\n}\n","// The claims that need a result record, and their state: checked, partial or not checked (roadmap C15, C16).\n// A claim is checked when a live record of kind `result` is about it, and the scope of the result is the scope of the\n// problem. A result of a different scope makes a partial claim. The workflow `Verify` runs each result again.\nimport { edgesOf, isLive } from \"./grammar.ts\";\nimport { readScope, sameScope, type Scope } from \"./scope.ts\";\nimport type { EntityRecord, Ontology } from \"./types.ts\";\n\n/** The problem statuses that are claims. The status `open` claims nothing. */\nexport const CLAIM_STATUSES: readonly string[] = [\"solved\", \"disproved\"];\n\n/**\n * The state of a claim. `checked`: a result about the claim has the scope of the problem. `partial`: results are about\n * the claim, but none has the scope of the problem. `not checked`: no result is about the claim.\n */\nexport type ClaimState = \"checked\" | \"partial\" | \"not checked\";\n\n/** A claim that needs a result record. */\nexport interface ResultClaim {\n /**\n * `status`: a problem has the status `solved` or `disproved`. `solves`: a function has the relation `solves` to a\n * problem.\n */\n readonly kind: \"status\" | \"solves\";\n /** The id of the problem of the claim. */\n readonly problem: string;\n /** The id of the function of a `solves` claim. */\n readonly function?: string | undefined;\n /** The status of the problem, for a `status` claim. */\n readonly status?: string | undefined;\n readonly state: ClaimState;\n /** The ids of the live result records about the claim, in id order. */\n readonly results: readonly string[];\n /** The ids of the results of `results` with the scope of the problem, in id order. */\n readonly full: readonly string[];\n}\n\n/** This function gives the scope of a record, or `undefined` when the record has no valid scope. */\nexport function scopeOf(record: EntityRecord | undefined): Scope | undefined {\n const value = record?.attrs[\"scope\"];\n if (value === undefined) return undefined;\n const scope = readScope(value);\n return typeof scope === \"string\" ? undefined : scope;\n}\n\n/**\n * This function tells if a result has the full scope of a problem. A problem or a result with no valid scope gives\n * `false`, so such a result cannot close a problem.\n */\nexport function hasFullScope(result: EntityRecord | undefined, problem: EntityRecord | undefined): boolean {\n const a = scopeOf(result);\n const b = scopeOf(problem);\n return a !== undefined && b !== undefined && sameScope(a, b);\n}\n\nfunction liveRecords(ontology: Ontology, kind: string): readonly EntityRecord[] {\n return ontology.records.map(({ record }) => record).filter((record) => record.kind === kind && isLive(record));\n}\n\n/**\n * This function gives each claim that needs a result record, with its state. A status claim needs a result about its\n * problem. A `solves` claim needs a result about its function and about its problem. The problem id orders the list.\n * A function can solve a part of a problem, so a partial `solves` claim is true. A partial status claim is not.\n */\nexport function resultClaimsOf(ontology: Ontology): readonly ResultClaim[] {\n const edges = edgesOf(ontology).filter(isLive);\n const results = new Set(liveRecords(ontology, \"result\").map((record) => record.id));\n const about = new Map<string, Set<string>>();\n for (const edge of edges) {\n if (edge.type !== \"about\" || !results.has(edge.from)) continue;\n const set = about.get(edge.from) ?? new Set<string>();\n set.add(edge.to);\n about.set(edge.from, set);\n }\n const byId = new Map(ontology.records.map(({ record }) => [record.id, record]));\n const resultsAbout = (...ids: readonly string[]): readonly string[] =>\n [...about].filter(([, targets]) => ids.every((id) => targets.has(id))).map(([id]) => id).sort();\n const fullOf = (problem: string, found: readonly string[]): readonly string[] =>\n found.filter((id) => hasFullScope(byId.get(id), byId.get(problem)));\n const stateOf = (found: readonly string[], full: readonly string[]): ClaimState =>\n full.length > 0 ? \"checked\" : found.length > 0 ? \"partial\" : \"not checked\";\n const claims: ResultClaim[] = [];\n for (const problem of liveRecords(ontology, \"problem\")) {\n const status = problem.attrs[\"status\"];\n if (typeof status !== \"string\" || !CLAIM_STATUSES.includes(status)) continue;\n const found = resultsAbout(problem.id);\n const full = fullOf(problem.id, found);\n claims.push({ kind: \"status\", problem: problem.id, status, state: stateOf(found, full), results: found, full });\n }\n const functions = new Set(liveRecords(ontology, \"function\").map((record) => record.id));\n for (const edge of edges) {\n if (edge.type !== \"solves\" || !functions.has(edge.from)) continue;\n const found = resultsAbout(edge.from, edge.to);\n const full = fullOf(edge.to, found);\n claims.push({ kind: \"solves\", problem: edge.to, function: edge.from, state: stateOf(found, full), results: found, full });\n }\n return claims.sort((a, b) => a.problem.localeCompare(b.problem) || a.kind.localeCompare(b.kind) || (a.function ?? \"\").localeCompare(b.function ?? \"\"));\n}\n\n/**\n * This function tells if a claim fails the rule of the results. A claim with no result fails. A status claim fails\n * also when none of its results has the scope of the problem: a partial result cannot close a problem.\n */\nexport function claimFails(claim: ResultClaim): boolean {\n return claim.state === \"not checked\" || (claim.kind === \"status\" && claim.state === \"partial\");\n}\n","// The read of one problem by the name that an outside catalog gives it (roadmap C12). A proof board, for example\n// lefttosolve, gives its agents the full Lean name of a statement, such as `Erdos242.erdos_242`. The read gives the\n// problem record of canon and each live result about it.\nimport { edgesOf, isLive } from \"./grammar.ts\";\nimport { hasFullScope, scopeOf } from \"./results.ts\";\nimport { scopeText } from \"./scope.ts\";\nimport type { EntityRecord, Ontology } from \"./types.ts\";\n\n/**\n * This function gives the key of a Lean name: the name with no `«` and `»` quotes. The board name\n * `Kourovka.20.51.kourovka_20_51` and the Lean name `Kourovka.«20.51».kourovka_20_51` have one key.\n */\nexport function leanKey(name: string): string {\n return name.trim().replace(/[«»]/g, \"\");\n}\n\n/** This function gives the Lean key of the formal statement of a record, or `undefined` when the record has none. */\nexport function formalKeyOf(record: EntityRecord): string | undefined {\n const formal = record.attrs[\"formal\"];\n return typeof formal === \"string\" && formal.trim() !== \"\" ? leanKey(formal) : undefined;\n}\n\n/** A live result about a problem. */\nexport interface ProblemResult {\n readonly id: string;\n /** The path of the file of the result. */\n readonly path: string;\n /** The text of the scope of the result, or an empty text when the result has no valid scope. */\n readonly scope: string;\n /** This value is true when the result has the scope of the problem, so the result settles all of the statement. */\n readonly full: boolean;\n /** The ids of the other records that the result is about, for example the function of the computation, in id order. */\n readonly about: readonly string[];\n}\n\n/** One problem and its live results. */\nexport interface ProblemRead {\n readonly problem: EntityRecord;\n /** The path of the file of the problem. */\n readonly path: string;\n /** The live results about the problem, in id order. */\n readonly results: readonly ProblemResult[];\n}\n\n/**\n * This function gives the id of a live problem. The problem has the id `name`, or its formal statement has the Lean key\n * of `name`. The function gives `undefined` when no live problem has the name. A page can use it with no Node.js.\n */\nexport function problemIdOf(records: Iterable<EntityRecord>, name: string): string | undefined {\n const id = name.trim();\n const key = leanKey(name);\n for (const record of records) {\n if (record.kind === \"problem\" && isLive(record) && (record.id === id || formalKeyOf(record) === key)) return record.id;\n }\n return undefined;\n}\n\n/** This function finds the live problem with the name `name`, as `problemIdOf` does, and its live results. */\nexport function findProblem(ontology: Ontology, name: string): ProblemRead | undefined {\n const id = problemIdOf(\n ontology.records.map(({ record }) => record),\n name,\n );\n const found = id === undefined ? undefined : ontology.records.find(({ record }) => record.id === id);\n if (found === undefined) return undefined;\n const { record: problem, path } = found;\n const entries = new Map(ontology.records.map((entry) => [entry.record.id, entry]));\n const about = new Map<string, Set<string>>();\n for (const edge of edgesOf(ontology)) {\n if (edge.type !== \"about\" || !isLive(edge)) continue;\n const set = about.get(edge.from) ?? new Set<string>();\n set.add(edge.to);\n about.set(edge.from, set);\n }\n const results: ProblemResult[] = [];\n for (const [from, targets] of about) {\n const entry = entries.get(from);\n if (entry?.record.kind !== \"result\" || !isLive(entry.record) || !targets.has(problem.id)) continue;\n const scope = scopeOf(entry.record);\n results.push({\n id: from,\n path: entry.path,\n scope: scope === undefined ? \"\" : scopeText(scope),\n full: hasFullScope(entry.record, problem),\n about: [...targets].filter((to) => to !== problem.id).sort(),\n });\n }\n return { problem, path, results: results.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) };\n}\n","// The target query: each gap of the ontology that one pull request can close, made from the records by rules.\nimport { arrayOf, booleanOf, numberOf, readArray, readText, recordOf, textOf } from \"@mark1russell7/optional/read\";\nimport { countOf, listOf } from \"@mark1russell7/text/english\";\nimport { edgesOf, isLive } from \"./grammar.ts\";\nimport { kindOfId, npmPackageId } from \"./ids.ts\";\nimport { hasFullScope } from \"./results.ts\";\nimport type { Edge, EntityRecord, GateName, Ontology } from \"./types.ts\";\n\nexport { leanKey, problemIdOf } from \"./problems.ts\";\nexport type { EdgeRecord, EntityRecord } from \"./types.ts\";\n\n/** The size of a piece of work. XS: under an hour. S: under a day. M: one to three days. L: up to two weeks. XL: more. */\nexport type Size = \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\";\n\n/** The sizes, the smallest first. */\nexport const SIZES: readonly Size[] = [\"XS\", \"S\", \"M\", \"L\", \"XL\"];\n\n/** What is true when a gap is closed, and the automatic tests that hold it. */\nexport interface Acceptance {\n readonly text: string;\n readonly checks: readonly string[];\n}\n\n/** The kinds of gap. The target query has one rule for each kind. */\nexport type Gap =\n | \"build-function\"\n | \"move-copy\"\n | \"find-copy\"\n | \"correct-map\"\n | \"first-package\"\n | \"first-release\"\n | \"make-repository\"\n | \"find-home\"\n | \"compute-problem\"\n | \"test-gate\";\n\n/** The repository of the ontology. A target that adds records to the ontology goes to it. */\nexport const ONTOLOGY_REPOSITORY = \"metrograph-labs/canon\";\n\n/** The npm package that has the map of homes. A target that changes the map goes to its repository. */\nexport const MAP_PACKAGE = \"@mark1russell7/conventions\";\n\n/** The attributes of a record of kind target. */\nexport type TargetAttrs = {\n readonly title: string;\n readonly gap: Gap;\n /** The repository, as owner/name, that gets the pull request. */\n readonly home: string;\n readonly area?: string;\n readonly size: Size;\n /** False when only the maintainer can close the gap, or when other targets come first. */\n readonly claimable: boolean;\n readonly acceptance: Acceptance;\n /** The fact of the ontology that makes the gap. */\n readonly why: string;\n /** The ids of the targets that come first. */\n readonly after?: readonly string[];\n /** The ids of the live results about the problem of the target that do not have the scope of the problem. */\n readonly partial?: readonly string[];\n};\n\n/** A record of kind target. */\nexport interface TargetRecord extends EntityRecord {\n readonly kind: \"target\";\n readonly attrs: TargetAttrs;\n}\n\n/** The indexes of the ontology that the rules read. */\nclass Graph {\n readonly byId: ReadonlyMap<string, EntityRecord>;\n private readonly edges: readonly Edge[];\n\n constructor(ontology: Ontology) {\n this.byId = new Map(ontology.records.map(({ record }) => [record.id, record]));\n this.edges = edgesOf(ontology).filter((edge) => isLive(edge) && kindOfId(edge.from) !== \"target\");\n }\n\n /** This function gives the live relations of the type `type` that start at `from`. */\n out(from: string, type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.from === from && edge.type === type);\n }\n\n /** This function gives the live relations of the type `type` that end at `to`. */\n in(to: string, type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.to === to && edge.type === type);\n }\n\n /** This function gives each live relation of the type `type`. */\n all(type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.type === type);\n }\n\n /** This function gives the text attribute `name` of the record `id`, or an empty text. */\n text(id: string, name: string): string {\n const value = this.byId.get(id)?.attrs[name];\n return typeof value === \"string\" ? value : \"\";\n }\n\n /** This function gives the repository of a record: the record itself, or the end of its chain of part-of relations. */\n repositoryOf(id: string): string | undefined {\n let current: string | undefined = id;\n for (let step = 0; step < 8 && current !== undefined; step += 1) {\n if (kindOfId(current) === \"repository\") return current;\n current = this.out(current, \"part-of\")[0]?.to;\n }\n return undefined;\n }\n\n /** This function gives the repository as owner/name. */\n slug(repositoryId: string): string {\n return `${this.text(repositoryId, \"owner\")}/${this.text(repositoryId, \"name\")}`;\n }\n\n /** This function gives the home of an area, with the state of the relation home-of. */\n homeOf(areaId: string): { readonly repository: string; readonly state: string } | undefined {\n const edge = this.in(areaId, \"home-of\")[0];\n return edge === undefined ? undefined : { repository: edge.from, state: String(edge.qualifiers[\"state\"] ?? \"\") };\n }\n\n /** This function gives the id of a live finding about each record of `about` with the claim `claim` and the result `result`. */\n finding(claim: string, result: string, about: readonly string[]): string | undefined {\n for (const [id, record] of this.byId) {\n if (record.kind !== \"finding\" || record.attrs[\"claim\"] !== claim || record.attrs[\"result\"] !== result || !isLive(record)) continue;\n const ends = new Set(this.out(id, \"about\").map((edge) => edge.to));\n if (about.every((end) => ends.has(end))) return id;\n }\n return undefined;\n }\n\n /** This function gives the name of a record in a title. A package or a function gives its name, an area its title, a repository its slug. */\n label(id: string): string {\n const kind = kindOfId(id);\n if (kind === \"repository\") return this.slug(id);\n if (kind === \"area\") return this.text(id, \"title\");\n return this.text(id, \"name\") || id;\n }\n}\n\n/** This function gives the id of a target from its gap and the id of its subject. */\nexport function targetId(gap: Gap, subject: string): string {\n return `target.${gap}.${subject.slice(kindOfId(subject).length + 1)}`;\n}\n\n/** The draft of a target that a rule gives. */\ninterface Draft extends Omit<TargetAttrs, \"after\"> {\n /** The record that the id of the target comes from. */\n readonly subject: string;\n /** The records that the target is about. The default is the subject. */\n readonly about?: readonly string[];\n readonly after?: readonly string[];\n}\n\n/** This function reads the size and the acceptance of a record, when it has them. */\nfunction workOf(record: EntityRecord | undefined): { size?: Size; acceptance?: Acceptance } {\n const size = record?.attrs[\"size\"];\n const acceptance = record?.attrs[\"acceptance\"];\n return {\n ...(typeof size === \"string\" && (SIZES as readonly string[]).includes(size) ? { size: size as Size } : {}),\n ...(acceptance !== undefined ? { acceptance: acceptance as Acceptance } : {}),\n };\n}\n\n/** Rule build-function: each planned function with a place gives a target to build it in that place. */\nfunction buildFunction(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"function\" || record.attrs[\"state\"] !== \"planned\") continue;\n const place = graph.out(id, \"planned-in\")[0]?.to;\n const repository = place === undefined ? undefined : graph.repositoryOf(place);\n if (place === undefined || repository === undefined) continue;\n const { size = \"M\", acceptance } = workOf(record);\n if (acceptance === undefined) continue;\n const area = graph.out(id, \"covers\")[0]?.to;\n drafts.push({\n subject: id,\n gap: \"build-function\",\n title: `Build ${graph.label(id)} in ${graph.label(place)}`,\n home: graph.slug(repository),\n ...(area !== undefined ? { area } : {}),\n size,\n claimable: graph.byId.get(repository)?.attrs[\"exists\"] === true,\n acceptance,\n why: `${graph.label(id)} is planned in ${graph.label(place)}: ${graph.text(id, \"summary\")}`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule move-copy: each package or function that holds a copy of the code of an area gives a target. The target moves the\n * copy to the home of the area. A copy that depends on a planned function comes after the target of that function. A\n * copy of an area with a planned home comes after the first package of that home.\n *\n * Rule correct-map: a finding that refutes the claim of the map of homes that a repository holds a copy gives a target.\n * The target removes the claim from the map. Rule find-copy gives no target for that claim.\n */\nfunction moveCopy(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n const mapRepository = graph.repositoryOf(npmPackageId(MAP_PACKAGE));\n const copies = graph.all(\"holds-copy\");\n const finer = codePairs(graph);\n for (const edge of copies) {\n const repository = graph.repositoryOf(edge.from);\n const home = graph.homeOf(edge.to);\n if (repository === undefined || home === undefined) continue;\n if (kindOfId(edge.from) === \"repository\" && finer.has(`${repository} ${edge.to}`)) continue;\n const after = [\n ...graph\n .out(edge.from, \"depends-on\")\n .filter((dependency) => graph.byId.get(dependency.to)?.attrs[\"state\"] === \"planned\")\n .map((dependency) => targetId(\"build-function\", dependency.to)),\n ...(home.state === \"planned\" ? [targetId(\"first-package\", edge.to)] : []),\n ];\n const ready = home.state === \"published\" || home.state === \"unpublished\";\n const area = graph.label(edge.to);\n const copy = graph.label(edge.from);\n const homeSlug = graph.slug(home.repository);\n const areaName = edge.to.slice(\"area.\".length);\n const refuted = kindOfId(edge.from) === \"repository\" ? graph.finding(\"holds-copy\", \"refuted\", [edge.from, edge.to]) : undefined;\n if (refuted !== undefined) {\n drafts.push({\n subject: `${edge.from}.${areaName}`,\n about: [edge.from, edge.to],\n gap: \"correct-map\",\n title: `Remove ${copy} from the map of homes for ${area}`,\n home: mapRepository === undefined ? ONTOLOGY_REPOSITORY : graph.slug(mapRepository),\n area: edge.to,\n size: \"XS\",\n claimable: false,\n acceptance: {\n text: `The map of homes no longer names ${copy} for ${area}.`,\n checks: [`The next import of the map gives no relation holds-copy from ${edge.from} to ${edge.to}.`, \"`pnpm canon targets --check` passes.\"],\n },\n why: `The finding ${refuted} refutes the claim of the map that ${copy} holds a copy of the code of ${area}. Only the maintainer changes the map.`,\n });\n continue;\n }\n if (kindOfId(edge.from) === \"repository\") continue;\n const { size = \"M\", acceptance } = workOf(graph.byId.get(edge.from));\n drafts.push({\n subject: edge.from,\n gap: \"move-copy\",\n title: `Replace ${copy} in ${graph.slug(repository)} with the code of the home of ${area}`,\n home: graph.slug(repository),\n area: edge.to,\n size,\n claimable: ready && after.length === 0,\n acceptance: acceptance ?? {\n text: `${graph.slug(repository)} keeps no copy of the code of ${area}. It uses the home ${homeSlug}.`,\n checks: [\n `The map of homes names ${graph.slug(repository)} in no alsoIn entry of the area ${edge.to.slice(\"area.\".length)}.`,\n `\\`conventions check\\` passes in ${graph.slug(repository)}: the rule home-package finds no copy of the area.`,\n ],\n },\n why: `${copy} holds code of ${area}, and the home of ${area} is ${homeSlug}${ready ? \"\" : ` (state ${home.state})`}.`,\n ...(after.length > 0 ? { after } : {}),\n });\n }\n return drafts;\n}\n\n/** This function gives each pair \"<repository> <area>\" where a record of a package or a function holds a copy of the code of the area. */\nfunction codePairs(graph: Graph): ReadonlySet<string> {\n const finer = graph.all(\"holds-copy\").filter((edge) => kindOfId(edge.from) !== \"repository\");\n return new Set(finer.map((edge) => `${graph.repositoryOf(edge.from) ?? \"\"} ${edge.to}`));\n}\n\n/** A function that a candidate names. */\ninterface Place {\n readonly file: string;\n readonly line: number;\n readonly name: string;\n}\n\n/** This function reads the places of a record of kind candidate. It drops a place with a bad field. */\nfunction placesOf(record: EntityRecord | undefined): readonly Place[] {\n return (\n readArray(record?.attrs[\"places\"], (value): Place | undefined => {\n const file = textOf(value, \"file\");\n const line = numberOf(value, \"line\");\n const name = textOf(value, \"name\");\n return file === undefined || line === undefined || name === undefined ? undefined : { file, line, name };\n }) ?? []\n );\n}\n\n/** The most places that the acceptance of a find-copy target names. The text tells the number of the others. */\nexport const PLACES_SHOWN = 5;\n\n/** This function gives the size of a find-copy target from the number of places: 1 is XS, 2 to 5 is S, more is M. */\nfunction findSize(places: number): Size {\n return places === 1 ? \"XS\" : places <= PLACES_SHOWN ? \"S\" : \"M\";\n}\n\n/**\n * Rule find-copy: a repository and an area give a target when a claim tells of a copy and no record names its code.\n * The target reads the code. It adds each copy to the ontology, or a finding that refutes the claim.\n *\n * - A claim is a relation holds-copy of the map of homes, or a record of kind candidate of the duplication atlas. The two\n * claims of one pair give one target.\n * - A pair with a package or a function of the repository for the area gives no target. Rule move-copy has it.\n * - A refuted finding about the pair gives no target. For a claim of the map, rule correct-map has it.\n * - The size comes from the number of places of the candidate. A claim of the map with no candidate has the size S.\n */\nfunction findCopy(graph: Graph): Draft[] {\n const pairs = new Map<string, { repository: string; area: string; map: boolean; candidate?: EntityRecord }>();\n for (const edge of graph.all(\"holds-copy\")) {\n if (kindOfId(edge.from) === \"repository\") pairs.set(`${edge.from} ${edge.to}`, { repository: edge.from, area: edge.to, map: true });\n }\n for (const record of graph.byId.values()) {\n if (record.kind !== \"candidate\" || !isLive(record)) continue;\n const ends = graph.out(record.id, \"about\").map((edge) => edge.to);\n const repository = ends.find((id) => kindOfId(id) === \"repository\");\n const area = ends.find((id) => kindOfId(id) === \"area\");\n if (repository === undefined || area === undefined) continue;\n const key = `${repository} ${area}`;\n pairs.set(key, { repository, area, map: pairs.get(key)?.map === true, candidate: record });\n }\n const finer = codePairs(graph);\n const drafts: Draft[] = [];\n for (const [key, { repository, area: areaId, map, candidate }] of pairs) {\n const home = graph.homeOf(areaId);\n if (home === undefined || home.repository === repository || finer.has(key)) continue;\n if (graph.finding(\"holds-copy\", \"refuted\", [repository, areaId]) !== undefined) continue;\n const area = graph.label(areaId);\n const copy = graph.label(repository);\n const places = placesOf(candidate);\n const commit = typeof candidate?.attrs[\"commit\"] === \"string\" ? candidate.attrs[\"commit\"] : \"\";\n const shown = places.slice(0, PLACES_SHOWN).map((place) => `\\`${place.file}:${String(place.line)}\\` ${place.name}`);\n const more = places.length > PLACES_SHOWN ? [countOf(places.length - PLACES_SHOWN, \"more place\")] : [];\n const found = `duplication atlas finds ${countOf(places.length, \"function\")} with the names of ${area} in ${copy} at the commit ${commit.slice(0, 12)}`;\n drafts.push({\n subject: `${repository}.${areaId.slice(\"area.\".length)}`,\n about: [repository, areaId],\n gap: \"find-copy\",\n title: `Find the code of ${area} in ${copy}`,\n home: ONTOLOGY_REPOSITORY,\n area: areaId,\n size: candidate === undefined ? \"S\" : findSize(places.length),\n claimable: home.state === \"published\" || home.state === \"unpublished\",\n acceptance: {\n text: `Each copy of the code of ${area} in ${copy} is a record of canon, or a finding with its evidence shows that there is no copy.`,\n checks: [\n `Each new record of kind function has the relations holds-copy to ${areaId} and part-of to ${repository}, a size and an acceptance.`,\n \"Each new record names the files of the copy on the main branch of the repository.\",\n ...(candidate === undefined ? [] : [`The read examines each place of ${candidate.id}: ${listOf([...shown, ...more])}.`]),\n `With no copy, a record of kind finding has the claim holds-copy, the result refuted, and the relations about to ${repository} and ${areaId}.`,\n \"`pnpm canon check` and `pnpm canon targets --check` pass.\",\n ],\n },\n why:\n candidate === undefined\n ? `The map of homes names ${copy} for ${area}, but no record names the code of the copy.`\n : map\n ? `The map of homes names ${copy} for ${area}, and the ${found}. No record names the code of the copy.`\n : `The ${found}. A match of names is not a proof of a copy, so an agent reads the code.`,\n });\n }\n return drafts;\n}\n\n/** A text that ends with this pattern ends a sentence, so the next sentence needs no full stop before it. */\nconst STOP = /[.!?]$/;\n\n/** Rule first-release: each package that is in its repository but not in the registry gives a target to release it. */\nfunction firstRelease(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"package\" || record.attrs[\"state\"] !== \"unpublished\") continue;\n const repository = graph.repositoryOf(id);\n if (repository === undefined) continue;\n const name = graph.label(id);\n const area = graph.out(id, \"covers\")[0]?.to;\n drafts.push({\n subject: id,\n gap: \"first-release\",\n title: `Release ${name} to npm`,\n home: graph.slug(repository),\n ...(area !== undefined ? { area } : {}),\n size: \"XS\",\n claimable: false,\n acceptance: { text: `npm has the package ${name}.`, checks: [`\\`npm view ${name} version\\` gives a version.`, \"The next import of the map gives the state published.\"] },\n why: `${name} is in ${graph.slug(repository)}, but npm does not have it. Only the maintainer releases a new package.`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule first-package: each planned home in a repository that exists, with no package that covers the area, gives a target\n * to make the first package. Rule make-repository: each home in a repository that does not exist gives a target to make it.\n */\nfunction firstPackageAndRepository(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const edge of graph.all(\"home-of\")) {\n const repository = graph.byId.get(edge.from);\n const area = graph.label(edge.to);\n const slug = graph.slug(edge.from);\n if (repository?.attrs[\"exists\"] === false) {\n drafts.push({\n subject: edge.from,\n gap: \"make-repository\",\n title: `Make the repository ${slug} for ${area}`,\n home: slug,\n area: edge.to,\n size: \"S\",\n claimable: false,\n acceptance: { text: `The public repository ${slug} exists.`, checks: [\"The next import of the map gives `exists: true` for the repository.\"] },\n why: `${slug} is the home of ${area}, but it does not exist. Only the maintainer makes a repository.`,\n });\n } else if (edge.qualifiers[\"state\"] === \"planned\" && graph.in(edge.to, \"covers\").every((cover) => graph.byId.get(cover.from)?.attrs[\"state\"] === \"planned\")) {\n drafts.push({\n subject: edge.to,\n gap: \"first-package\",\n title: `Make the first package of ${area} in ${slug}`,\n home: slug,\n area: edge.to,\n size: \"M\",\n claimable: false,\n acceptance: { text: `${slug} has a package for ${area}.`, checks: [\"The next import of the map gives a package that covers the area.\"] },\n why: `${slug} is the planned home of ${area}, and no package covers it. A new package needs the maintainer.`,\n });\n }\n }\n return drafts;\n}\n\n/**\n * Rule find-home: each area with no home gives a target to choose its home in the map of homes. Only the maintainer\n * chooses a home.\n */\nfunction findHome(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n const mapRepository = graph.repositoryOf(npmPackageId(MAP_PACKAGE));\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"area\" || graph.in(id, \"home-of\").length > 0) continue;\n const area = graph.label(id);\n drafts.push({\n subject: id,\n gap: \"find-home\",\n title: `Choose a home for ${area}`,\n home: mapRepository === undefined ? ONTOLOGY_REPOSITORY : graph.slug(mapRepository),\n area: id,\n size: \"S\",\n claimable: false,\n acceptance: {\n text: `The map of homes has a row for ${area}, with its home repository and its packages.`,\n checks: [\"The next import of the map gives the relation home-of to the area.\", \"`pnpm canon check` passes.\"],\n },\n why: `${area} has no home. Only the maintainer chooses a home.`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule compute-problem: each open problem with a computation gives a target to build the computation in the home of an\n * area that it needs. It comes after the targets that give a home to each area it needs, and that build each planned\n * function it needs.\n */\nfunction computeProblem(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"problem\" || record.attrs[\"status\"] !== \"open\" || graph.text(id, \"computation\") === \"\") continue;\n const needs = graph.out(id, \"needs\").map((edge) => edge.to);\n const after: string[] = [];\n let place: { readonly repository: string; readonly state: string } | undefined;\n // Each needed area counts, not only the first: a problem that needs a solver waits for the solver package too.\n let live = true;\n for (const need of needs) {\n if (kindOfId(need) === \"area\") {\n const home = graph.homeOf(need);\n if (home === undefined) {\n after.push(targetId(\"find-home\", need));\n live = false;\n continue;\n }\n place ??= home;\n if (home.state !== \"published\" && home.state !== \"unpublished\") {\n live = false;\n if (home.state === \"planned\") after.push(targetId(\"first-package\", need));\n }\n } else if (graph.byId.get(need)?.attrs[\"state\"] === \"planned\") {\n after.push(targetId(\"build-function\", need));\n }\n }\n const ready = place !== undefined && live;\n // A result of a different scope is a record on the target, and the target stays open (roadmap C16).\n const partial = graph\n .in(id, \"about\")\n .map((edge) => edge.from)\n .filter((from) => {\n const result = graph.byId.get(from);\n return result?.kind === \"result\" && isLive(result) && !hasFullScope(result, record);\n })\n .sort();\n const title = graph.text(id, \"title\");\n const certificate = graph.text(id, \"certificate\") || \"witness\";\n const { size = \"M\", acceptance } = workOf(record);\n drafts.push({\n subject: id,\n gap: \"compute-problem\",\n title: `Compute ${title}`,\n home: place === undefined ? ONTOLOGY_REPOSITORY : graph.slug(place.repository),\n size,\n claimable: ready && after.length === 0,\n acceptance: acceptance ?? {\n text: `A function computes ${graph.text(id, \"computation\")}, and each result has a certificate of the kind ${certificate}.`,\n checks: [\n `A record of kind function has the relation solves to ${id}.`,\n certificate === \"ledger\" ? \"A test checks that the ledger names each range that is done, with no gap and no overlap.\" : \"A test checks each witness against the statement of the problem.\",\n \"`pnpm canon check` passes.\",\n ],\n },\n why: `${title} is open, and a computation helps: ${graph.text(id, \"computation\")}${partial.length > 0 ? `${STOP.test(graph.text(id, \"computation\")) ? \"\" : \".\"} ${countOf(partial.length, \"result\")} ${partial.length === 1 ? \"settles\" : \"settle\"} only a part of its scope.` : \"\"}`,\n ...(after.length > 0 ? { after } : {}),\n ...(partial.length > 0 ? { partial } : {}),\n });\n }\n return drafts;\n}\n\n/** The gates that rule test-gate asks of each home repository. The read also gives the gate rigs, with no target. */\nexport const NECESSARY_GATES: readonly NecessaryGate[] = [\"mutation\", \"property\", \"speed\"];\n\n/** A gate that rule test-gate asks of each home repository. */\nexport type NecessaryGate = Exclude<GateName, \"rigs\">;\n\n/** The work to add each gate of `NECESSARY_GATES` to a repository `slug`. */\nfunction addWork(gate: NecessaryGate, slug: string): Pick<TargetAttrs, \"title\" | \"size\" | \"claimable\" | \"acceptance\"> {\n const next = (gateName: string): string => `The next import of canon gives the ${gateName} gate of ${slug} with \\`exists: true\\`.`;\n if (gate === \"mutation\") {\n return {\n title: `Add the mutation gate to ${slug}`,\n size: \"M\",\n claimable: true,\n acceptance: {\n text: `${slug} has a lane file of mutation tests and a workflow that calls \\`reusable-mutation.yml\\` of \\`mark1russell7/template\\`.`,\n checks: [`The lane file names each package of ${slug}, and each package has a gate.`, \"The workflow gives a score for each package, at or above its gate.\", next(\"mutation\")],\n },\n };\n }\n if (gate === \"property\") {\n return {\n title: `Add property tests to ${slug}`,\n size: \"S\",\n claimable: true,\n acceptance: {\n text: `A package of ${slug} has property tests with \\`fast-check\\` or \\`@mark1russell7/rigor-testkit\\`.`,\n checks: [\"A property test checks a law of the code of the home, and it fails when the law breaks.\", \"The tests of the repository pass in CI.\", next(\"property\")],\n },\n };\n }\n return {\n title: `Add a speed gate to ${slug}`,\n size: \"M\",\n claimable: false,\n acceptance: {\n text: `A workflow of ${slug} starts a bench of \\`@mark1russell7/rigor-bench\\` on each pull request, and its verdict can fail the pull request.`,\n checks: [\"A package file names `@mark1russell7/rigor-bench` in its dependencies.\", \"The bench job gives the verdict of `gateOf` or `notSlowerVerdict`, and a slower case fails the job.\", next(\"speed\")],\n },\n };\n}\n\n/**\n * Rule test-gate: each home repository that exists gives a target for each gate of `NECESSARY_GATES` that its read\n * finds absent. It also gives a target for a gate with no necessary check. A gate with no read gives no target.\n *\n * - An absent mutation or property gate is claimable. A speed gate needs the maintainer, who chooses the timed cases.\n * - A gate that is not a necessary check needs the maintainer, because only the maintainer changes the rules of a branch.\n */\nfunction testGate(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"repository\" || record.attrs[\"exists\"] !== true || graph.out(id, \"home-of\").length === 0) continue;\n const read = recordOf(record.attrs, \"test_gates\");\n const branch = textOf(read, \"branch\") ?? \"\";\n const slug = graph.slug(id);\n for (const gate of NECESSARY_GATES) {\n const fact = recordOf(recordOf(read, \"gates\"), gate);\n const exists = booleanOf(fact, \"exists\");\n const necessary = booleanOf(fact, \"necessary\");\n const base = { subject: `${id}.${gate}`, about: [id], gap: \"test-gate\" as const, home: slug };\n if (exists === false) {\n const missing = arrayOf(fact, \"missing\", readText) ?? [];\n drafts.push({ ...base, ...addWork(gate, slug), why: `The read of ${slug} on the branch ${branch} does not find ${listOf(missing.length > 0 ? missing : [`the ${gate} gate`])}.` });\n } else if (exists === true && necessary === false) {\n const checks = (arrayOf(fact, \"checks\", readText) ?? []).map((check) => `\\`${check}\\``);\n drafts.push({\n ...base,\n title: `Make the ${gate} gate a necessary check of ${slug}`,\n size: gate === \"mutation\" ? \"S\" : \"XS\",\n claimable: false,\n acceptance: {\n text: `The rules of the branch ${branch} of ${slug} name a check of the ${gate} gate as a necessary check.`,\n checks: [\n ...(gate === \"mutation\" ? [\"A workflow on each pull request calls `reusable-mutation.yml` with the input `changed`, so its check starts on each pull request.\"] : []),\n checks.length > 0 ? `\\`gh api repos/${slug}/rules/branches/${branch}\\` names the check ${listOf(checks, { conjunction: \"or\" })}.` : `\\`gh api repos/${slug}/rules/branches/${branch}\\` names a check of a job of the ${gate} gate.`,\n `The next import of canon gives the ${gate} gate of ${slug} with \\`necessary: true\\`.`,\n ],\n },\n why: `${slug} has the ${gate} gate, but the rules of the branch ${branch} name no check of it as necessary. Only the maintainer changes the rules of a branch.`,\n });\n }\n }\n }\n return drafts;\n}\n\n/** This function gives the order of two targets: the claimable targets first, then the smaller, then by id. */\nexport function compareTargets(a: TargetRecord, b: TargetRecord): number {\n if (a.attrs.claimable !== b.attrs.claimable) return a.attrs.claimable ? -1 : 1;\n const size = SIZES.indexOf(a.attrs.size) - SIZES.indexOf(b.attrs.size);\n if (size !== 0) return size;\n return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n}\n\n/**\n * This function is the target query. It applies each rule to the records, and gives each target in the order of\n * `compareTargets`. It reads no record of kind target, so its result depends on the other records only.\n */\nexport function targetsOf(ontology: Ontology): readonly TargetRecord[] {\n const graph = new Graph(ontology);\n const drafts = [\n ...buildFunction(graph),\n ...moveCopy(graph),\n ...findCopy(graph),\n ...firstRelease(graph),\n ...firstPackageAndRepository(graph),\n ...findHome(graph),\n ...computeProblem(graph),\n ...testGate(graph),\n ];\n return drafts\n .map(({ subject, about = [subject], after, ...attrs }): TargetRecord => ({\n id: targetId(attrs.gap, subject),\n kind: \"target\",\n attrs: after === undefined ? attrs : { ...attrs, after },\n envelope: { derived: true },\n edges: about.map((to) => ({ type: \"about\", to })),\n }))\n .sort(compareTargets);\n}\n"],"mappings":";;;;;;AAIA,MAAa,kBAAkB;;AAG/B,MAAa,eAAe;;AAG5B,MAAa,qBAAqB;;;;;;AAOlC,SAAgB,OAAO,MAAsB;CAE3C,OADc,KAAK,QAAQ,sBAAsB,OAAO,CAAC,CAAC,YAC/C,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,YAAY,EAAE;AACjE;;AAGA,SAAgB,OAAO,MAAc,GAAG,OAAkC;CACxE,OAAO,CAAC,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;AAC9C;;AAGA,SAAgB,SAAS,IAAoB;CAC3C,MAAM,MAAM,GAAG,QAAQ,GAAG;CAC1B,OAAO,MAAM,IAAI,KAAK,GAAG,MAAM,GAAG,GAAG;AACvC;;;;;AAMA,SAAgB,SAAS,IAAoB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AAK,OAAO;EAC/B,MAAM;EACN,OAAO,UAAU,KAAA,IAAY,QAAQ;GAAE,GAAG;GAAO;EAAM;EACvD,UAAU,EAAE,SAAS,KAAK;EAC1B,OAAO,MAAM,KAAK,QAAQ;GAAE,MAAM;GAAS;EAAG,EAAE;CAClD,EAAE,CAAC,CACF,KAAK,cAAc;AACxB"}
|
|
@@ -138,6 +138,40 @@ interface TestGates {
|
|
|
138
138
|
readonly necessary_checks?: readonly string[];
|
|
139
139
|
readonly gates: Readonly<Record<GateName, GateFact>>;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* This function gives the key of a Lean name: the name with no `«` and `»` quotes. The board name
|
|
143
|
+
* `Kourovka.20.51.kourovka_20_51` and the Lean name `Kourovka.«20.51».kourovka_20_51` have one key.
|
|
144
|
+
*/
|
|
145
|
+
declare function leanKey(name: string): string;
|
|
146
|
+
/** This function gives the Lean key of the formal statement of a record, or `undefined` when the record has none. */
|
|
147
|
+
declare function formalKeyOf(record: EntityRecord): string | undefined;
|
|
148
|
+
/** A live result about a problem. */
|
|
149
|
+
interface ProblemResult {
|
|
150
|
+
readonly id: string;
|
|
151
|
+
/** The path of the file of the result. */
|
|
152
|
+
readonly path: string;
|
|
153
|
+
/** The text of the scope of the result, or an empty text when the result has no valid scope. */
|
|
154
|
+
readonly scope: string;
|
|
155
|
+
/** This value is true when the result has the scope of the problem, so the result settles all of the statement. */
|
|
156
|
+
readonly full: boolean;
|
|
157
|
+
/** The ids of the other records that the result is about, for example the function of the computation, in id order. */
|
|
158
|
+
readonly about: readonly string[];
|
|
159
|
+
}
|
|
160
|
+
/** One problem and its live results. */
|
|
161
|
+
interface ProblemRead {
|
|
162
|
+
readonly problem: EntityRecord;
|
|
163
|
+
/** The path of the file of the problem. */
|
|
164
|
+
readonly path: string;
|
|
165
|
+
/** The live results about the problem, in id order. */
|
|
166
|
+
readonly results: readonly ProblemResult[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* This function gives the id of a live problem. The problem has the id `name`, or its formal statement has the Lean key
|
|
170
|
+
* of `name`. The function gives `undefined` when no live problem has the name. A page can use it with no Node.js.
|
|
171
|
+
*/
|
|
172
|
+
declare function problemIdOf(records: Iterable<EntityRecord>, name: string): string | undefined;
|
|
173
|
+
/** This function finds the live problem with the name `name`, as `problemIdOf` does, and its live results. */
|
|
174
|
+
declare function findProblem(ontology: Ontology, name: string): ProblemRead | undefined;
|
|
141
175
|
/** The size of a piece of work. XS: under an hour. S: under a day. M: one to three days. L: up to two weeks. XL: more. */
|
|
142
176
|
type Size = "XS" | "S" | "M" | "L" | "XL";
|
|
143
177
|
/** The sizes, the smallest first. */
|
|
@@ -191,4 +225,4 @@ declare function compareTargets(a: TargetRecord, b: TargetRecord): number;
|
|
|
191
225
|
* `compareTargets`. It reads no record of kind target, so its result depends on the other records only.
|
|
192
226
|
*/
|
|
193
227
|
declare function targetsOf(ontology: Ontology): readonly TargetRecord[];
|
|
194
|
-
export {
|
|
228
|
+
export { KindDef as A, EntityRecord as C, GateName as D, GateFact as E, RelationKindDef as F, TestGates as I, LoadedRecord as M, Ontology as N, Grammar as O, Problem as P, EdgeRecord as S, FacetDef as T, findProblem as _, NecessaryGate as a, problemIdOf as b, SIZES as c, TargetRecord as d, compareTargets as f, ProblemResult as g, ProblemRead as h, NECESSARY_GATES as i, KindMode as j, JsonSchema as k, Size as l, targetsOf as m, Gap as n, ONTOLOGY_REPOSITORY as o, targetId as p, MAP_PACKAGE as r, PLACES_SHOWN as s, Acceptance as t, TargetAttrs as u, formalKeyOf as v, Envelope as w, Edge as x, leanKey as y };
|
package/build/targets.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { Acceptance, type EdgeRecord, type EntityRecord, Gap, MAP_PACKAGE, NECESSARY_GATES, NecessaryGate, ONTOLOGY_REPOSITORY, PLACES_SHOWN, SIZES, Size, TargetAttrs, TargetRecord, compareTargets, targetId, targetsOf };
|
|
1
|
+
import { C as EntityRecord, S as EdgeRecord, a as NecessaryGate, b as problemIdOf, c as SIZES, d as TargetRecord, f as compareTargets, i as NECESSARY_GATES, l as Size, m as targetsOf, n as Gap, o as ONTOLOGY_REPOSITORY, p as targetId, r as MAP_PACKAGE, s as PLACES_SHOWN, t as Acceptance, u as TargetAttrs, y as leanKey } from "./targets-D3vj1inS.mjs";
|
|
2
|
+
export { Acceptance, type EdgeRecord, type EntityRecord, Gap, MAP_PACKAGE, NECESSARY_GATES, NecessaryGate, ONTOLOGY_REPOSITORY, PLACES_SHOWN, SIZES, Size, TargetAttrs, TargetRecord, compareTargets, leanKey, problemIdOf, targetId, targetsOf };
|
package/build/targets.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as MAP_PACKAGE, n as NECESSARY_GATES, r as ONTOLOGY_REPOSITORY, i as PLACES_SHOWN, a as SIZES, o as compareTargets, s as targetId, c as targetsOf } from "./targets-
|
|
1
|
+
export { t as MAP_PACKAGE, n as NECESSARY_GATES, r as ONTOLOGY_REPOSITORY, i as PLACES_SHOWN, a as SIZES, o as compareTargets, d as leanKey, f as problemIdOf, s as targetId, c as targetsOf } from "./targets-BwC2nZGy.mjs";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/canon-ontology",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "The ontology of canon: the grammar, the read and the check of the records, the import of the map of homes and the target query.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ontology",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targets-DsUgzuOM.mjs","names":[],"sources":["../src/ids.ts","../src/grammar.ts","../src/scope.ts","../src/results.ts","../src/targets.ts"],"sourcesContent":["// The ids of the records and the paths of their files.\nimport { formatPurl } from \"@mark1russell7/package-id\";\n\n/** The folder of the record files, relative to the root of the repository. */\nexport const ONTOLOGY_FOLDER = \"ontology\";\n\n/** The file of the grammar, relative to the root of the repository. */\nexport const GRAMMAR_FILE = \"schema/grammar.json\";\n\n/** The file of the JSON Schema of one record file, relative to the root of the repository. */\nexport const RECORD_SCHEMA_FILE = \"schema/record.schema.json\";\n\n/**\n * This function gives one part of an id from a name. The part is in lower case. A hyphen goes before each upper-case\n * letter that follows a lower-case letter or a digit. One hyphen replaces each run of other characters. For example,\n * `greatCircleKm` gives `great-circle-km`, and `@mark1russell7/text` gives `mark1russell7-text`.\n */\nexport function idPart(name: string): string {\n const words = name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n return words.replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n}\n\n/** This function gives an id from a kind and the parts of a name. Each part goes through `idPart`. */\nexport function makeId(kind: string, ...parts: readonly string[]): string {\n return [kind, ...parts.map(idPart)].join(\".\");\n}\n\n/** This function gives the kind at the start of an id: the text before the first dot. */\nexport function kindOfId(id: string): string {\n const dot = id.indexOf(\".\");\n return dot < 0 ? id : id.slice(0, dot);\n}\n\n/**\n * This function gives the path of the file of a record, relative to the root of the repository. The path is the folder\n * of its kind, then the rest of the id. For example, `area.statistics` is in `ontology/area/statistics.json`.\n */\nexport function pathOfId(id: string): string {\n const kind = kindOfId(id);\n return `${ONTOLOGY_FOLDER}/${kind}/${id.slice(kind.length + 1)}.json`;\n}\n\n/** This function gives the id of the repository `owner/name`. */\nexport function repositoryId(owner: string, name: string): string {\n return makeId(\"repository\", owner, name);\n}\n\n/** This function gives the id of the npm package `name`. A scoped name gives the scope and the name as two parts. */\nexport function npmPackageId(name: string): string {\n const scoped = /^@([^/]+)\\/(.+)$/.exec(name);\n return scoped === null ? makeId(\"package\", \"npm\", name) : makeId(\"package\", \"npm\", scoped[1] ?? \"\", scoped[2] ?? \"\");\n}\n\n/** This function gives the package URL of the npm package `name`, as the purl specification writes it. */\nexport function npmPurl(name: string): string {\n const scoped = /^(@[^/]+)\\/(.+)$/.exec(name);\n const purl = scoped === null ? { type: \"npm\", name } : { type: \"npm\", namespace: scoped[1] ?? \"\", name: scoped[2] ?? \"\" };\n const text = formatPurl(purl);\n if (text === undefined) throw new Error(`The npm name ${name} gives no package URL.`);\n return text;\n}\n","// The queries over the grammar: the kinds, their ancestors and the relation kinds.\nimport type { Edge, Envelope, Grammar, KindDef, Ontology, RelationKindDef } from \"./types.ts\";\n\n/** This function gives the kind with the name `name`, or undefined. */\nexport function kindOf(grammar: Grammar, name: string): KindDef | undefined {\n return grammar.kinds.find((kind) => kind.name === name);\n}\n\n/** This function gives the relation kind with the name `name`, or undefined. */\nexport function relationOf(grammar: Grammar, name: string): RelationKindDef | undefined {\n return grammar.relations.find((relation) => relation.name === name);\n}\n\n/**\n * This function gives the kind `name` and each ancestor kind, the nearest first. A loop of parents ends the list at the\n * first kind that comes again. A kind that the grammar does not have gives an empty list.\n */\nexport function lineageOf(grammar: Grammar, name: string): readonly string[] {\n const lineage: string[] = [];\n let kind = kindOf(grammar, name);\n while (kind !== undefined && !lineage.includes(kind.name)) {\n lineage.push(kind.name);\n kind = kind.parent === null ? undefined : kindOf(grammar, kind.parent);\n }\n return lineage;\n}\n\n/** This function tells if a record of the kind `name` is also a record of one of the kinds `allowed`. */\nexport function isKindIn(grammar: Grammar, name: string, allowed: readonly string[]): boolean {\n return lineageOf(grammar, name).some((kind) => allowed.includes(kind));\n}\n\n/** This function gives each relation of the ontology with its two ends, in the order of the record files. */\nexport function edgesOf(ontology: Ontology): readonly Edge[] {\n return ontology.records.flatMap(({ record }) =>\n (record.edges ?? []).map((edge) => ({\n from: record.id,\n type: edge.type,\n to: edge.to,\n qualifiers: edge.qualifiers ?? {},\n envelope: edge.envelope ?? {},\n })),\n );\n}\n\n/** This function tells if a relation or a record is live: no other record supersedes it, and nobody retired it. */\nexport function isLive(item: { readonly envelope?: Envelope | undefined }): boolean {\n return item.envelope?.superseded_by === undefined && item.envelope?.retired_from === undefined;\n}\n","// The scope of a claim: the values of one integer variable that a result settles, or that the statement of a problem\n// covers (roadmap C16). A target closes only when the scope of a checked claim equals the scope of its problem. A result\n// of another scope is a partial claim: the target shows it, and the target stays open.\nimport { isRecord } from \"@mark1russell7/optional/read\";\nimport { sorted } from \"@mark1russell7/rigor-statistics\";\n\n/** The largest modulus of a scope. A scope lists its residues, so a larger modulus gives a record that is too long. */\nexport const SCOPE_MODULUS_LIMIT = 1_000_000;\n\n/**\n * A scope is a set of integers. A value v of `variable` is in the set when three conditions are true. `from` ≤ v. When\n * `to` has a value, v ≤ `to`. The residue v mod `modulus` is in `residues`.\n */\nexport interface Scope {\n readonly variable: string;\n readonly from: bigint;\n readonly to: bigint | undefined;\n /** This value is 1 when the scope has no class condition. */\n readonly modulus: number;\n /** These values are the residues modulo `modulus`, the least first, each once. */\n readonly residues: readonly number[];\n}\n\nconst INTEGER = /^-?(0|[1-9][0-9]*)$/;\nconst VARIABLE = /^[a-z][a-z0-9]*$/;\n\nfunction readBound(value: unknown, name: string): bigint | string {\n return typeof value === \"string\" && INTEGER.test(value) ? BigInt(value) : `The field ${name} of the scope is not an integer as a decimal text.`;\n}\n\nfunction readResidues(value: unknown, name: string, modulus: number): number[] | string {\n if (!Array.isArray(value) || value.length === 0) return `The field ${name} of the scope is not a list of residues.`;\n const seen = new Set<number>();\n for (const residue of value) {\n if (!Number.isSafeInteger(residue) || (residue as number) < 0 || (residue as number) >= modulus) return `The field ${name} of the scope has ${JSON.stringify(residue)}, which is not a residue from 0 to ${String(modulus - 1)}.`;\n if (seen.has(residue as number)) return `The field ${name} of the scope has ${String(residue)} two times.`;\n seen.add(residue as number);\n }\n return sorted([...seen]);\n}\n\n/**\n * This function reads the JSON form of a scope. The form has `variable`, `from` and optionally `to`, with the bounds as\n * decimal texts. It can also have `modulus` with one of `residues` and `except`. The function gives the scope, or the\n * text of the problem.\n */\nexport function readScope(value: unknown): Scope | string {\n if (!isRecord(value)) return \"The scope is not an object.\";\n const variable = value[\"variable\"];\n if (typeof variable !== \"string\" || !VARIABLE.test(variable)) return \"The field variable of the scope is not a name.\";\n const from = readBound(value[\"from\"], \"from\");\n if (typeof from === \"string\") return from;\n const to = value[\"to\"] === undefined ? undefined : readBound(value[\"to\"], \"to\");\n if (typeof to === \"string\") return to;\n if (to !== undefined && to < from) return \"The field to of the scope is less than the field from.\";\n const modulusValue = value[\"modulus\"];\n if (modulusValue === undefined) {\n if (value[\"residues\"] !== undefined || value[\"except\"] !== undefined) return \"The scope has residues but no modulus.\";\n return { variable, from, to, modulus: 1, residues: [0] };\n }\n if (!Number.isSafeInteger(modulusValue) || (modulusValue as number) < 1 || (modulusValue as number) > SCOPE_MODULUS_LIMIT) {\n return `The field modulus of the scope is not an integer from 1 to ${String(SCOPE_MODULUS_LIMIT)}.`;\n }\n const modulus = modulusValue as number;\n if ((value[\"residues\"] === undefined) === (value[\"except\"] === undefined)) return \"The scope with a modulus has one of residues and except.\";\n if (value[\"residues\"] !== undefined) {\n const residues = readResidues(value[\"residues\"], \"residues\", modulus);\n return typeof residues === \"string\" ? residues : { variable, from, to, modulus, residues };\n }\n const except = readResidues(value[\"except\"], \"except\", modulus);\n if (typeof except === \"string\") return except;\n const out = new Set(except);\n const residues = Array.from({ length: modulus }, (_, r) => r).filter((r) => !out.has(r));\n return residues.length === 0 ? \"The field except of the scope has each residue, so the scope is empty.\" : { variable, from, to, modulus, residues };\n}\n\nfunction residueOf(value: bigint, modulus: number): number {\n const m = BigInt(modulus);\n return Number(((value % m) + m) % m);\n}\n\n/** This function gives the least modulus d of the classes: the residues modulo the modulus repeat with the period d. */\nfunction leastPeriod(modulus: number, residues: ReadonlySet<number>): number {\n for (let d = 1; d < modulus; d++) {\n if (modulus % d !== 0) continue;\n if ([...residues].every((r) => residues.has((r + d) % modulus))) return d;\n }\n return modulus;\n}\n\n/**\n * This function gives the canonical form of a scope, or `undefined` for an empty scope. The canonical form has the\n * least modulus of its classes. Its `from` and `to` are values of the set.\n */\nexport function canonicalScope(scope: Scope): Scope | undefined {\n const all = new Set(scope.residues.map((r) => ((r % scope.modulus) + scope.modulus) % scope.modulus));\n if (all.size === 0) return undefined;\n const modulus = leastPeriod(scope.modulus, all);\n const residues = sorted([...new Set([...all].map((r) => r % modulus))]);\n const set = new Set(residues);\n let step = 0;\n while (!set.has((residueOf(scope.from, modulus) + step) % modulus)) step++;\n const from = scope.from + BigInt(step);\n let to: bigint | undefined;\n if (scope.to !== undefined) {\n step = 0;\n while (!set.has((residueOf(scope.to, modulus) - step + modulus) % modulus)) step++;\n to = scope.to - BigInt(step);\n if (to < from) return undefined;\n }\n return { variable: scope.variable, from, to, modulus, residues };\n}\n\n/**\n * This function tells if two scopes have the same canonical form. Two equal unbounded sets have the same form. Two\n * equal bounded sets can have different classes, and then the function gives `false`. So a claim of a short range\n * keeps its target open, and a wrong `true` cannot close a target.\n */\nexport function sameScope(a: Scope, b: Scope): boolean {\n const x = canonicalScope(a);\n const y = canonicalScope(b);\n if (x === undefined || y === undefined) return false;\n return (\n x.variable === y.variable &&\n x.from === y.from &&\n x.to === y.to &&\n x.modulus === y.modulus &&\n x.residues.length === y.residues.length &&\n x.residues.every((r, i) => r === y.residues[i])\n );\n}\n\n/** This function tells if a value is in a scope. */\nexport function inScope(scope: Scope, value: bigint): boolean {\n return value >= scope.from && (scope.to === undefined || value <= scope.to) && scope.residues.includes(residueOf(value, scope.modulus));\n}\n\n/** The most residues that the text of a scope shows. */\nconst SHOWN_RESIDUES = 8;\n\nfunction residueText(residues: readonly number[]): string {\n const shown = residues.slice(0, SHOWN_RESIDUES).join(\", \");\n return residues.length > SHOWN_RESIDUES ? `{${shown} and ${String(residues.length - SHOWN_RESIDUES)} more}` : `{${shown}}`;\n}\n\n/** This function gives the scope in words, for example `n ≥ 3, n mod 840 not in {1, 121}`. */\nexport function scopeText(scope: Scope): string {\n const v = scope.variable;\n const range = scope.to === undefined ? `${v} ≥ ${String(scope.from)}` : `${String(scope.from)} ≤ ${v} ≤ ${String(scope.to)}`;\n if (scope.modulus === 1) return range;\n const has = new Set(scope.residues);\n const missing = Array.from({ length: scope.modulus }, (_, r) => r).filter((r) => !has.has(r));\n return missing.length < scope.residues.length\n ? `${range}, ${v} mod ${String(scope.modulus)} not in ${residueText(missing)}`\n : `${range}, ${v} mod ${String(scope.modulus)} in ${residueText(scope.residues)}`;\n}\n","// The claims that need a result record, and their state: checked, partial or not checked (roadmap C15, C16).\n// A claim is checked when a live record of kind `result` is about it, and the scope of the result is the scope of the\n// problem. A result of a different scope makes a partial claim. The workflow `Verify` runs each result again.\nimport { edgesOf, isLive } from \"./grammar.ts\";\nimport { readScope, sameScope, type Scope } from \"./scope.ts\";\nimport type { EntityRecord, Ontology } from \"./types.ts\";\n\n/** The problem statuses that are claims. The status `open` claims nothing. */\nexport const CLAIM_STATUSES: readonly string[] = [\"solved\", \"disproved\"];\n\n/**\n * The state of a claim. `checked`: a result about the claim has the scope of the problem. `partial`: results are about\n * the claim, but none has the scope of the problem. `not checked`: no result is about the claim.\n */\nexport type ClaimState = \"checked\" | \"partial\" | \"not checked\";\n\n/** A claim that needs a result record. */\nexport interface ResultClaim {\n /**\n * `status`: a problem has the status `solved` or `disproved`. `solves`: a function has the relation `solves` to a\n * problem.\n */\n readonly kind: \"status\" | \"solves\";\n /** The id of the problem of the claim. */\n readonly problem: string;\n /** The id of the function of a `solves` claim. */\n readonly function?: string | undefined;\n /** The status of the problem, for a `status` claim. */\n readonly status?: string | undefined;\n readonly state: ClaimState;\n /** The ids of the live result records about the claim, in id order. */\n readonly results: readonly string[];\n /** The ids of the results of `results` with the scope of the problem, in id order. */\n readonly full: readonly string[];\n}\n\n/** This function gives the scope of a record, or `undefined` when the record has no valid scope. */\nexport function scopeOf(record: EntityRecord | undefined): Scope | undefined {\n const value = record?.attrs[\"scope\"];\n if (value === undefined) return undefined;\n const scope = readScope(value);\n return typeof scope === \"string\" ? undefined : scope;\n}\n\n/**\n * This function tells if a result has the full scope of a problem. A problem or a result with no valid scope gives\n * `false`, so such a result cannot close a problem.\n */\nexport function hasFullScope(result: EntityRecord | undefined, problem: EntityRecord | undefined): boolean {\n const a = scopeOf(result);\n const b = scopeOf(problem);\n return a !== undefined && b !== undefined && sameScope(a, b);\n}\n\nfunction liveRecords(ontology: Ontology, kind: string): readonly EntityRecord[] {\n return ontology.records.map(({ record }) => record).filter((record) => record.kind === kind && isLive(record));\n}\n\n/**\n * This function gives each claim that needs a result record, with its state. A status claim needs a result about its\n * problem. A `solves` claim needs a result about its function and about its problem. The problem id orders the list.\n * A function can solve a part of a problem, so a partial `solves` claim is true. A partial status claim is not.\n */\nexport function resultClaimsOf(ontology: Ontology): readonly ResultClaim[] {\n const edges = edgesOf(ontology).filter(isLive);\n const results = new Set(liveRecords(ontology, \"result\").map((record) => record.id));\n const about = new Map<string, Set<string>>();\n for (const edge of edges) {\n if (edge.type !== \"about\" || !results.has(edge.from)) continue;\n const set = about.get(edge.from) ?? new Set<string>();\n set.add(edge.to);\n about.set(edge.from, set);\n }\n const byId = new Map(ontology.records.map(({ record }) => [record.id, record]));\n const resultsAbout = (...ids: readonly string[]): readonly string[] =>\n [...about].filter(([, targets]) => ids.every((id) => targets.has(id))).map(([id]) => id).sort();\n const fullOf = (problem: string, found: readonly string[]): readonly string[] =>\n found.filter((id) => hasFullScope(byId.get(id), byId.get(problem)));\n const stateOf = (found: readonly string[], full: readonly string[]): ClaimState =>\n full.length > 0 ? \"checked\" : found.length > 0 ? \"partial\" : \"not checked\";\n const claims: ResultClaim[] = [];\n for (const problem of liveRecords(ontology, \"problem\")) {\n const status = problem.attrs[\"status\"];\n if (typeof status !== \"string\" || !CLAIM_STATUSES.includes(status)) continue;\n const found = resultsAbout(problem.id);\n const full = fullOf(problem.id, found);\n claims.push({ kind: \"status\", problem: problem.id, status, state: stateOf(found, full), results: found, full });\n }\n const functions = new Set(liveRecords(ontology, \"function\").map((record) => record.id));\n for (const edge of edges) {\n if (edge.type !== \"solves\" || !functions.has(edge.from)) continue;\n const found = resultsAbout(edge.from, edge.to);\n const full = fullOf(edge.to, found);\n claims.push({ kind: \"solves\", problem: edge.to, function: edge.from, state: stateOf(found, full), results: found, full });\n }\n return claims.sort((a, b) => a.problem.localeCompare(b.problem) || a.kind.localeCompare(b.kind) || (a.function ?? \"\").localeCompare(b.function ?? \"\"));\n}\n\n/**\n * This function tells if a claim fails the rule of the results. A claim with no result fails. A status claim fails\n * also when none of its results has the scope of the problem: a partial result cannot close a problem.\n */\nexport function claimFails(claim: ResultClaim): boolean {\n return claim.state === \"not checked\" || (claim.kind === \"status\" && claim.state === \"partial\");\n}\n","// The target query: each gap of the ontology that one pull request can close, made from the records by rules.\nimport { arrayOf, booleanOf, numberOf, readArray, readText, recordOf, textOf } from \"@mark1russell7/optional/read\";\nimport { countOf, listOf } from \"@mark1russell7/text/english\";\nimport { edgesOf, isLive } from \"./grammar.ts\";\nimport { kindOfId, npmPackageId } from \"./ids.ts\";\nimport { hasFullScope } from \"./results.ts\";\nimport type { Edge, EntityRecord, GateName, Ontology } from \"./types.ts\";\n\nexport type { EdgeRecord, EntityRecord } from \"./types.ts\";\n\n/** The size of a piece of work. XS: under an hour. S: under a day. M: one to three days. L: up to two weeks. XL: more. */\nexport type Size = \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\";\n\n/** The sizes, the smallest first. */\nexport const SIZES: readonly Size[] = [\"XS\", \"S\", \"M\", \"L\", \"XL\"];\n\n/** What is true when a gap is closed, and the automatic tests that hold it. */\nexport interface Acceptance {\n readonly text: string;\n readonly checks: readonly string[];\n}\n\n/** The kinds of gap. The target query has one rule for each kind. */\nexport type Gap =\n | \"build-function\"\n | \"move-copy\"\n | \"find-copy\"\n | \"correct-map\"\n | \"first-package\"\n | \"first-release\"\n | \"make-repository\"\n | \"find-home\"\n | \"compute-problem\"\n | \"test-gate\";\n\n/** The repository of the ontology. A target that adds records to the ontology goes to it. */\nexport const ONTOLOGY_REPOSITORY = \"metrograph-labs/canon\";\n\n/** The npm package that has the map of homes. A target that changes the map goes to its repository. */\nexport const MAP_PACKAGE = \"@mark1russell7/conventions\";\n\n/** The attributes of a record of kind target. */\nexport type TargetAttrs = {\n readonly title: string;\n readonly gap: Gap;\n /** The repository, as owner/name, that gets the pull request. */\n readonly home: string;\n readonly area?: string;\n readonly size: Size;\n /** False when only the maintainer can close the gap, or when other targets come first. */\n readonly claimable: boolean;\n readonly acceptance: Acceptance;\n /** The fact of the ontology that makes the gap. */\n readonly why: string;\n /** The ids of the targets that come first. */\n readonly after?: readonly string[];\n /** The ids of the live results about the problem of the target that do not have the scope of the problem. */\n readonly partial?: readonly string[];\n};\n\n/** A record of kind target. */\nexport interface TargetRecord extends EntityRecord {\n readonly kind: \"target\";\n readonly attrs: TargetAttrs;\n}\n\n/** The indexes of the ontology that the rules read. */\nclass Graph {\n readonly byId: ReadonlyMap<string, EntityRecord>;\n private readonly edges: readonly Edge[];\n\n constructor(ontology: Ontology) {\n this.byId = new Map(ontology.records.map(({ record }) => [record.id, record]));\n this.edges = edgesOf(ontology).filter((edge) => isLive(edge) && kindOfId(edge.from) !== \"target\");\n }\n\n /** This function gives the live relations of the type `type` that start at `from`. */\n out(from: string, type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.from === from && edge.type === type);\n }\n\n /** This function gives the live relations of the type `type` that end at `to`. */\n in(to: string, type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.to === to && edge.type === type);\n }\n\n /** This function gives each live relation of the type `type`. */\n all(type: string): readonly Edge[] {\n return this.edges.filter((edge) => edge.type === type);\n }\n\n /** This function gives the text attribute `name` of the record `id`, or an empty text. */\n text(id: string, name: string): string {\n const value = this.byId.get(id)?.attrs[name];\n return typeof value === \"string\" ? value : \"\";\n }\n\n /** This function gives the repository of a record: the record itself, or the end of its chain of part-of relations. */\n repositoryOf(id: string): string | undefined {\n let current: string | undefined = id;\n for (let step = 0; step < 8 && current !== undefined; step += 1) {\n if (kindOfId(current) === \"repository\") return current;\n current = this.out(current, \"part-of\")[0]?.to;\n }\n return undefined;\n }\n\n /** This function gives the repository as owner/name. */\n slug(repositoryId: string): string {\n return `${this.text(repositoryId, \"owner\")}/${this.text(repositoryId, \"name\")}`;\n }\n\n /** This function gives the home of an area, with the state of the relation home-of. */\n homeOf(areaId: string): { readonly repository: string; readonly state: string } | undefined {\n const edge = this.in(areaId, \"home-of\")[0];\n return edge === undefined ? undefined : { repository: edge.from, state: String(edge.qualifiers[\"state\"] ?? \"\") };\n }\n\n /** This function gives the id of a live finding about each record of `about` with the claim `claim` and the result `result`. */\n finding(claim: string, result: string, about: readonly string[]): string | undefined {\n for (const [id, record] of this.byId) {\n if (record.kind !== \"finding\" || record.attrs[\"claim\"] !== claim || record.attrs[\"result\"] !== result || !isLive(record)) continue;\n const ends = new Set(this.out(id, \"about\").map((edge) => edge.to));\n if (about.every((end) => ends.has(end))) return id;\n }\n return undefined;\n }\n\n /** This function gives the name of a record in a title. A package or a function gives its name, an area its title, a repository its slug. */\n label(id: string): string {\n const kind = kindOfId(id);\n if (kind === \"repository\") return this.slug(id);\n if (kind === \"area\") return this.text(id, \"title\");\n return this.text(id, \"name\") || id;\n }\n}\n\n/** This function gives the id of a target from its gap and the id of its subject. */\nexport function targetId(gap: Gap, subject: string): string {\n return `target.${gap}.${subject.slice(kindOfId(subject).length + 1)}`;\n}\n\n/** The draft of a target that a rule gives. */\ninterface Draft extends Omit<TargetAttrs, \"after\"> {\n /** The record that the id of the target comes from. */\n readonly subject: string;\n /** The records that the target is about. The default is the subject. */\n readonly about?: readonly string[];\n readonly after?: readonly string[];\n}\n\n/** This function reads the size and the acceptance of a record, when it has them. */\nfunction workOf(record: EntityRecord | undefined): { size?: Size; acceptance?: Acceptance } {\n const size = record?.attrs[\"size\"];\n const acceptance = record?.attrs[\"acceptance\"];\n return {\n ...(typeof size === \"string\" && (SIZES as readonly string[]).includes(size) ? { size: size as Size } : {}),\n ...(acceptance !== undefined ? { acceptance: acceptance as Acceptance } : {}),\n };\n}\n\n/** Rule build-function: each planned function with a place gives a target to build it in that place. */\nfunction buildFunction(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"function\" || record.attrs[\"state\"] !== \"planned\") continue;\n const place = graph.out(id, \"planned-in\")[0]?.to;\n const repository = place === undefined ? undefined : graph.repositoryOf(place);\n if (place === undefined || repository === undefined) continue;\n const { size = \"M\", acceptance } = workOf(record);\n if (acceptance === undefined) continue;\n const area = graph.out(id, \"covers\")[0]?.to;\n drafts.push({\n subject: id,\n gap: \"build-function\",\n title: `Build ${graph.label(id)} in ${graph.label(place)}`,\n home: graph.slug(repository),\n ...(area !== undefined ? { area } : {}),\n size,\n claimable: graph.byId.get(repository)?.attrs[\"exists\"] === true,\n acceptance,\n why: `${graph.label(id)} is planned in ${graph.label(place)}: ${graph.text(id, \"summary\")}`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule move-copy: each package or function that holds a copy of the code of an area gives a target. The target moves the\n * copy to the home of the area. A copy that depends on a planned function comes after the target of that function. A\n * copy of an area with a planned home comes after the first package of that home.\n *\n * Rule correct-map: a finding that refutes the claim of the map of homes that a repository holds a copy gives a target.\n * The target removes the claim from the map. Rule find-copy gives no target for that claim.\n */\nfunction moveCopy(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n const mapRepository = graph.repositoryOf(npmPackageId(MAP_PACKAGE));\n const copies = graph.all(\"holds-copy\");\n const finer = codePairs(graph);\n for (const edge of copies) {\n const repository = graph.repositoryOf(edge.from);\n const home = graph.homeOf(edge.to);\n if (repository === undefined || home === undefined) continue;\n if (kindOfId(edge.from) === \"repository\" && finer.has(`${repository} ${edge.to}`)) continue;\n const after = [\n ...graph\n .out(edge.from, \"depends-on\")\n .filter((dependency) => graph.byId.get(dependency.to)?.attrs[\"state\"] === \"planned\")\n .map((dependency) => targetId(\"build-function\", dependency.to)),\n ...(home.state === \"planned\" ? [targetId(\"first-package\", edge.to)] : []),\n ];\n const ready = home.state === \"published\" || home.state === \"unpublished\";\n const area = graph.label(edge.to);\n const copy = graph.label(edge.from);\n const homeSlug = graph.slug(home.repository);\n const areaName = edge.to.slice(\"area.\".length);\n const refuted = kindOfId(edge.from) === \"repository\" ? graph.finding(\"holds-copy\", \"refuted\", [edge.from, edge.to]) : undefined;\n if (refuted !== undefined) {\n drafts.push({\n subject: `${edge.from}.${areaName}`,\n about: [edge.from, edge.to],\n gap: \"correct-map\",\n title: `Remove ${copy} from the map of homes for ${area}`,\n home: mapRepository === undefined ? ONTOLOGY_REPOSITORY : graph.slug(mapRepository),\n area: edge.to,\n size: \"XS\",\n claimable: false,\n acceptance: {\n text: `The map of homes no longer names ${copy} for ${area}.`,\n checks: [`The next import of the map gives no relation holds-copy from ${edge.from} to ${edge.to}.`, \"`pnpm canon targets --check` passes.\"],\n },\n why: `The finding ${refuted} refutes the claim of the map that ${copy} holds a copy of the code of ${area}. Only the maintainer changes the map.`,\n });\n continue;\n }\n if (kindOfId(edge.from) === \"repository\") continue;\n const { size = \"M\", acceptance } = workOf(graph.byId.get(edge.from));\n drafts.push({\n subject: edge.from,\n gap: \"move-copy\",\n title: `Replace ${copy} in ${graph.slug(repository)} with the code of the home of ${area}`,\n home: graph.slug(repository),\n area: edge.to,\n size,\n claimable: ready && after.length === 0,\n acceptance: acceptance ?? {\n text: `${graph.slug(repository)} keeps no copy of the code of ${area}. It uses the home ${homeSlug}.`,\n checks: [\n `The map of homes names ${graph.slug(repository)} in no alsoIn entry of the area ${edge.to.slice(\"area.\".length)}.`,\n `\\`conventions check\\` passes in ${graph.slug(repository)}: the rule home-package finds no copy of the area.`,\n ],\n },\n why: `${copy} holds code of ${area}, and the home of ${area} is ${homeSlug}${ready ? \"\" : ` (state ${home.state})`}.`,\n ...(after.length > 0 ? { after } : {}),\n });\n }\n return drafts;\n}\n\n/** This function gives each pair \"<repository> <area>\" where a record of a package or a function holds a copy of the code of the area. */\nfunction codePairs(graph: Graph): ReadonlySet<string> {\n const finer = graph.all(\"holds-copy\").filter((edge) => kindOfId(edge.from) !== \"repository\");\n return new Set(finer.map((edge) => `${graph.repositoryOf(edge.from) ?? \"\"} ${edge.to}`));\n}\n\n/** A function that a candidate names. */\ninterface Place {\n readonly file: string;\n readonly line: number;\n readonly name: string;\n}\n\n/** This function reads the places of a record of kind candidate. It drops a place with a bad field. */\nfunction placesOf(record: EntityRecord | undefined): readonly Place[] {\n return (\n readArray(record?.attrs[\"places\"], (value): Place | undefined => {\n const file = textOf(value, \"file\");\n const line = numberOf(value, \"line\");\n const name = textOf(value, \"name\");\n return file === undefined || line === undefined || name === undefined ? undefined : { file, line, name };\n }) ?? []\n );\n}\n\n/** The most places that the acceptance of a find-copy target names. The text tells the number of the others. */\nexport const PLACES_SHOWN = 5;\n\n/** This function gives the size of a find-copy target from the number of places: 1 is XS, 2 to 5 is S, more is M. */\nfunction findSize(places: number): Size {\n return places === 1 ? \"XS\" : places <= PLACES_SHOWN ? \"S\" : \"M\";\n}\n\n/**\n * Rule find-copy: a repository and an area give a target when a claim tells of a copy and no record names its code.\n * The target reads the code. It adds each copy to the ontology, or a finding that refutes the claim.\n *\n * - A claim is a relation holds-copy of the map of homes, or a record of kind candidate of the duplication atlas. The two\n * claims of one pair give one target.\n * - A pair with a package or a function of the repository for the area gives no target. Rule move-copy has it.\n * - A refuted finding about the pair gives no target. For a claim of the map, rule correct-map has it.\n * - The size comes from the number of places of the candidate. A claim of the map with no candidate has the size S.\n */\nfunction findCopy(graph: Graph): Draft[] {\n const pairs = new Map<string, { repository: string; area: string; map: boolean; candidate?: EntityRecord }>();\n for (const edge of graph.all(\"holds-copy\")) {\n if (kindOfId(edge.from) === \"repository\") pairs.set(`${edge.from} ${edge.to}`, { repository: edge.from, area: edge.to, map: true });\n }\n for (const record of graph.byId.values()) {\n if (record.kind !== \"candidate\" || !isLive(record)) continue;\n const ends = graph.out(record.id, \"about\").map((edge) => edge.to);\n const repository = ends.find((id) => kindOfId(id) === \"repository\");\n const area = ends.find((id) => kindOfId(id) === \"area\");\n if (repository === undefined || area === undefined) continue;\n const key = `${repository} ${area}`;\n pairs.set(key, { repository, area, map: pairs.get(key)?.map === true, candidate: record });\n }\n const finer = codePairs(graph);\n const drafts: Draft[] = [];\n for (const [key, { repository, area: areaId, map, candidate }] of pairs) {\n const home = graph.homeOf(areaId);\n if (home === undefined || home.repository === repository || finer.has(key)) continue;\n if (graph.finding(\"holds-copy\", \"refuted\", [repository, areaId]) !== undefined) continue;\n const area = graph.label(areaId);\n const copy = graph.label(repository);\n const places = placesOf(candidate);\n const commit = typeof candidate?.attrs[\"commit\"] === \"string\" ? candidate.attrs[\"commit\"] : \"\";\n const shown = places.slice(0, PLACES_SHOWN).map((place) => `\\`${place.file}:${String(place.line)}\\` ${place.name}`);\n const more = places.length > PLACES_SHOWN ? [countOf(places.length - PLACES_SHOWN, \"more place\")] : [];\n const found = `duplication atlas finds ${countOf(places.length, \"function\")} with the names of ${area} in ${copy} at the commit ${commit.slice(0, 12)}`;\n drafts.push({\n subject: `${repository}.${areaId.slice(\"area.\".length)}`,\n about: [repository, areaId],\n gap: \"find-copy\",\n title: `Find the code of ${area} in ${copy}`,\n home: ONTOLOGY_REPOSITORY,\n area: areaId,\n size: candidate === undefined ? \"S\" : findSize(places.length),\n claimable: home.state === \"published\" || home.state === \"unpublished\",\n acceptance: {\n text: `Each copy of the code of ${area} in ${copy} is a record of canon, or a finding with its evidence shows that there is no copy.`,\n checks: [\n `Each new record of kind function has the relations holds-copy to ${areaId} and part-of to ${repository}, a size and an acceptance.`,\n \"Each new record names the files of the copy on the main branch of the repository.\",\n ...(candidate === undefined ? [] : [`The read examines each place of ${candidate.id}: ${listOf([...shown, ...more])}.`]),\n `With no copy, a record of kind finding has the claim holds-copy, the result refuted, and the relations about to ${repository} and ${areaId}.`,\n \"`pnpm canon check` and `pnpm canon targets --check` pass.\",\n ],\n },\n why:\n candidate === undefined\n ? `The map of homes names ${copy} for ${area}, but no record names the code of the copy.`\n : map\n ? `The map of homes names ${copy} for ${area}, and the ${found}. No record names the code of the copy.`\n : `The ${found}. A match of names is not a proof of a copy, so an agent reads the code.`,\n });\n }\n return drafts;\n}\n\n/** A text that ends with this pattern ends a sentence, so the next sentence needs no full stop before it. */\nconst STOP = /[.!?]$/;\n\n/** Rule first-release: each package that is in its repository but not in the registry gives a target to release it. */\nfunction firstRelease(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"package\" || record.attrs[\"state\"] !== \"unpublished\") continue;\n const repository = graph.repositoryOf(id);\n if (repository === undefined) continue;\n const name = graph.label(id);\n const area = graph.out(id, \"covers\")[0]?.to;\n drafts.push({\n subject: id,\n gap: \"first-release\",\n title: `Release ${name} to npm`,\n home: graph.slug(repository),\n ...(area !== undefined ? { area } : {}),\n size: \"XS\",\n claimable: false,\n acceptance: { text: `npm has the package ${name}.`, checks: [`\\`npm view ${name} version\\` gives a version.`, \"The next import of the map gives the state published.\"] },\n why: `${name} is in ${graph.slug(repository)}, but npm does not have it. Only the maintainer releases a new package.`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule first-package: each planned home in a repository that exists, with no package that covers the area, gives a target\n * to make the first package. Rule make-repository: each home in a repository that does not exist gives a target to make it.\n */\nfunction firstPackageAndRepository(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const edge of graph.all(\"home-of\")) {\n const repository = graph.byId.get(edge.from);\n const area = graph.label(edge.to);\n const slug = graph.slug(edge.from);\n if (repository?.attrs[\"exists\"] === false) {\n drafts.push({\n subject: edge.from,\n gap: \"make-repository\",\n title: `Make the repository ${slug} for ${area}`,\n home: slug,\n area: edge.to,\n size: \"S\",\n claimable: false,\n acceptance: { text: `The public repository ${slug} exists.`, checks: [\"The next import of the map gives `exists: true` for the repository.\"] },\n why: `${slug} is the home of ${area}, but it does not exist. Only the maintainer makes a repository.`,\n });\n } else if (edge.qualifiers[\"state\"] === \"planned\" && graph.in(edge.to, \"covers\").every((cover) => graph.byId.get(cover.from)?.attrs[\"state\"] === \"planned\")) {\n drafts.push({\n subject: edge.to,\n gap: \"first-package\",\n title: `Make the first package of ${area} in ${slug}`,\n home: slug,\n area: edge.to,\n size: \"M\",\n claimable: false,\n acceptance: { text: `${slug} has a package for ${area}.`, checks: [\"The next import of the map gives a package that covers the area.\"] },\n why: `${slug} is the planned home of ${area}, and no package covers it. A new package needs the maintainer.`,\n });\n }\n }\n return drafts;\n}\n\n/**\n * Rule find-home: each area with no home gives a target to choose its home in the map of homes. Only the maintainer\n * chooses a home.\n */\nfunction findHome(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n const mapRepository = graph.repositoryOf(npmPackageId(MAP_PACKAGE));\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"area\" || graph.in(id, \"home-of\").length > 0) continue;\n const area = graph.label(id);\n drafts.push({\n subject: id,\n gap: \"find-home\",\n title: `Choose a home for ${area}`,\n home: mapRepository === undefined ? ONTOLOGY_REPOSITORY : graph.slug(mapRepository),\n area: id,\n size: \"S\",\n claimable: false,\n acceptance: {\n text: `The map of homes has a row for ${area}, with its home repository and its packages.`,\n checks: [\"The next import of the map gives the relation home-of to the area.\", \"`pnpm canon check` passes.\"],\n },\n why: `${area} has no home. Only the maintainer chooses a home.`,\n });\n }\n return drafts;\n}\n\n/**\n * Rule compute-problem: each open problem with a computation gives a target to build the computation in the home of an\n * area that it needs. It comes after the targets that give a home to each area it needs, and that build each planned\n * function it needs.\n */\nfunction computeProblem(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"problem\" || record.attrs[\"status\"] !== \"open\" || graph.text(id, \"computation\") === \"\") continue;\n const needs = graph.out(id, \"needs\").map((edge) => edge.to);\n const after: string[] = [];\n let place: { readonly repository: string; readonly state: string } | undefined;\n // Each needed area counts, not only the first: a problem that needs a solver waits for the solver package too.\n let live = true;\n for (const need of needs) {\n if (kindOfId(need) === \"area\") {\n const home = graph.homeOf(need);\n if (home === undefined) {\n after.push(targetId(\"find-home\", need));\n live = false;\n continue;\n }\n place ??= home;\n if (home.state !== \"published\" && home.state !== \"unpublished\") {\n live = false;\n if (home.state === \"planned\") after.push(targetId(\"first-package\", need));\n }\n } else if (graph.byId.get(need)?.attrs[\"state\"] === \"planned\") {\n after.push(targetId(\"build-function\", need));\n }\n }\n const ready = place !== undefined && live;\n // A result of a different scope is a record on the target, and the target stays open (roadmap C16).\n const partial = graph\n .in(id, \"about\")\n .map((edge) => edge.from)\n .filter((from) => {\n const result = graph.byId.get(from);\n return result?.kind === \"result\" && isLive(result) && !hasFullScope(result, record);\n })\n .sort();\n const title = graph.text(id, \"title\");\n const certificate = graph.text(id, \"certificate\") || \"witness\";\n const { size = \"M\", acceptance } = workOf(record);\n drafts.push({\n subject: id,\n gap: \"compute-problem\",\n title: `Compute ${title}`,\n home: place === undefined ? ONTOLOGY_REPOSITORY : graph.slug(place.repository),\n size,\n claimable: ready && after.length === 0,\n acceptance: acceptance ?? {\n text: `A function computes ${graph.text(id, \"computation\")}, and each result has a certificate of the kind ${certificate}.`,\n checks: [\n `A record of kind function has the relation solves to ${id}.`,\n certificate === \"ledger\" ? \"A test checks that the ledger names each range that is done, with no gap and no overlap.\" : \"A test checks each witness against the statement of the problem.\",\n \"`pnpm canon check` passes.\",\n ],\n },\n why: `${title} is open, and a computation helps: ${graph.text(id, \"computation\")}${partial.length > 0 ? `${STOP.test(graph.text(id, \"computation\")) ? \"\" : \".\"} ${countOf(partial.length, \"result\")} ${partial.length === 1 ? \"settles\" : \"settle\"} only a part of its scope.` : \"\"}`,\n ...(after.length > 0 ? { after } : {}),\n ...(partial.length > 0 ? { partial } : {}),\n });\n }\n return drafts;\n}\n\n/** The gates that rule test-gate asks of each home repository. The read also gives the gate rigs, with no target. */\nexport const NECESSARY_GATES: readonly NecessaryGate[] = [\"mutation\", \"property\", \"speed\"];\n\n/** A gate that rule test-gate asks of each home repository. */\nexport type NecessaryGate = Exclude<GateName, \"rigs\">;\n\n/** The work to add each gate of `NECESSARY_GATES` to a repository `slug`. */\nfunction addWork(gate: NecessaryGate, slug: string): Pick<TargetAttrs, \"title\" | \"size\" | \"claimable\" | \"acceptance\"> {\n const next = (gateName: string): string => `The next import of canon gives the ${gateName} gate of ${slug} with \\`exists: true\\`.`;\n if (gate === \"mutation\") {\n return {\n title: `Add the mutation gate to ${slug}`,\n size: \"M\",\n claimable: true,\n acceptance: {\n text: `${slug} has a lane file of mutation tests and a workflow that calls \\`reusable-mutation.yml\\` of \\`mark1russell7/template\\`.`,\n checks: [`The lane file names each package of ${slug}, and each package has a gate.`, \"The workflow gives a score for each package, at or above its gate.\", next(\"mutation\")],\n },\n };\n }\n if (gate === \"property\") {\n return {\n title: `Add property tests to ${slug}`,\n size: \"S\",\n claimable: true,\n acceptance: {\n text: `A package of ${slug} has property tests with \\`fast-check\\` or \\`@mark1russell7/rigor-testkit\\`.`,\n checks: [\"A property test checks a law of the code of the home, and it fails when the law breaks.\", \"The tests of the repository pass in CI.\", next(\"property\")],\n },\n };\n }\n return {\n title: `Add a speed gate to ${slug}`,\n size: \"M\",\n claimable: false,\n acceptance: {\n text: `A workflow of ${slug} starts a bench of \\`@mark1russell7/rigor-bench\\` on each pull request, and its verdict can fail the pull request.`,\n checks: [\"A package file names `@mark1russell7/rigor-bench` in its dependencies.\", \"The bench job gives the verdict of `gateOf` or `notSlowerVerdict`, and a slower case fails the job.\", next(\"speed\")],\n },\n };\n}\n\n/**\n * Rule test-gate: each home repository that exists gives a target for each gate of `NECESSARY_GATES` that its read\n * finds absent. It also gives a target for a gate with no necessary check. A gate with no read gives no target.\n *\n * - An absent mutation or property gate is claimable. A speed gate needs the maintainer, who chooses the timed cases.\n * - A gate that is not a necessary check needs the maintainer, because only the maintainer changes the rules of a branch.\n */\nfunction testGate(graph: Graph): Draft[] {\n const drafts: Draft[] = [];\n for (const [id, record] of graph.byId) {\n if (record.kind !== \"repository\" || record.attrs[\"exists\"] !== true || graph.out(id, \"home-of\").length === 0) continue;\n const read = recordOf(record.attrs, \"test_gates\");\n const branch = textOf(read, \"branch\") ?? \"\";\n const slug = graph.slug(id);\n for (const gate of NECESSARY_GATES) {\n const fact = recordOf(recordOf(read, \"gates\"), gate);\n const exists = booleanOf(fact, \"exists\");\n const necessary = booleanOf(fact, \"necessary\");\n const base = { subject: `${id}.${gate}`, about: [id], gap: \"test-gate\" as const, home: slug };\n if (exists === false) {\n const missing = arrayOf(fact, \"missing\", readText) ?? [];\n drafts.push({ ...base, ...addWork(gate, slug), why: `The read of ${slug} on the branch ${branch} does not find ${listOf(missing.length > 0 ? missing : [`the ${gate} gate`])}.` });\n } else if (exists === true && necessary === false) {\n const checks = (arrayOf(fact, \"checks\", readText) ?? []).map((check) => `\\`${check}\\``);\n drafts.push({\n ...base,\n title: `Make the ${gate} gate a necessary check of ${slug}`,\n size: gate === \"mutation\" ? \"S\" : \"XS\",\n claimable: false,\n acceptance: {\n text: `The rules of the branch ${branch} of ${slug} name a check of the ${gate} gate as a necessary check.`,\n checks: [\n ...(gate === \"mutation\" ? [\"A workflow on each pull request calls `reusable-mutation.yml` with the input `changed`, so its check starts on each pull request.\"] : []),\n checks.length > 0 ? `\\`gh api repos/${slug}/rules/branches/${branch}\\` names the check ${listOf(checks, { conjunction: \"or\" })}.` : `\\`gh api repos/${slug}/rules/branches/${branch}\\` names a check of a job of the ${gate} gate.`,\n `The next import of canon gives the ${gate} gate of ${slug} with \\`necessary: true\\`.`,\n ],\n },\n why: `${slug} has the ${gate} gate, but the rules of the branch ${branch} name no check of it as necessary. Only the maintainer changes the rules of a branch.`,\n });\n }\n }\n }\n return drafts;\n}\n\n/** This function gives the order of two targets: the claimable targets first, then the smaller, then by id. */\nexport function compareTargets(a: TargetRecord, b: TargetRecord): number {\n if (a.attrs.claimable !== b.attrs.claimable) return a.attrs.claimable ? -1 : 1;\n const size = SIZES.indexOf(a.attrs.size) - SIZES.indexOf(b.attrs.size);\n if (size !== 0) return size;\n return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n}\n\n/**\n * This function is the target query. It applies each rule to the records, and gives each target in the order of\n * `compareTargets`. It reads no record of kind target, so its result depends on the other records only.\n */\nexport function targetsOf(ontology: Ontology): readonly TargetRecord[] {\n const graph = new Graph(ontology);\n const drafts = [\n ...buildFunction(graph),\n ...moveCopy(graph),\n ...findCopy(graph),\n ...firstRelease(graph),\n ...firstPackageAndRepository(graph),\n ...findHome(graph),\n ...computeProblem(graph),\n ...testGate(graph),\n ];\n return drafts\n .map(({ subject, about = [subject], after, ...attrs }): TargetRecord => ({\n id: targetId(attrs.gap, subject),\n kind: \"target\",\n attrs: after === undefined ? attrs : { ...attrs, after },\n envelope: { derived: true },\n edges: about.map((to) => ({ type: \"about\", to })),\n }))\n .sort(compareTargets);\n}\n"],"mappings":";;;;;;AAIA,MAAa,kBAAkB;;AAG/B,MAAa,eAAe;;AAG5B,MAAa,qBAAqB;;;;;;AAOlC,SAAgB,OAAO,MAAsB;CAE3C,OADc,KAAK,QAAQ,sBAAsB,OAAO,CAAC,CAAC,YAC/C,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,YAAY,EAAE;AACjE;;AAGA,SAAgB,OAAO,MAAc,GAAG,OAAkC;CACxE,OAAO,CAAC,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;AAC9C;;AAGA,SAAgB,SAAS,IAAoB;CAC3C,MAAM,MAAM,GAAG,QAAQ,GAAG;CAC1B,OAAO,MAAM,IAAI,KAAK,GAAG,MAAM,GAAG,GAAG;AACvC;;;;;AAMA,SAAgB,SAAS,IAAoB;CAC3C,MAAM,OAAO,SAAS,EAAE;CACxB,OAAO,GAAG,gBAAgB,GAAG,KAAK,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,EAAE;AACjE;;AAGA,SAAgB,aAAa,OAAe,MAAsB;CAChE,OAAO,OAAO,cAAc,OAAO,IAAI;AACzC;;AAGA,SAAgB,aAAa,MAAsB;CACjD,MAAM,SAAS,mBAAmB,KAAK,IAAI;CAC3C,OAAO,WAAW,OAAO,O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